Topic "forfile with winscp not working-Need to put folder of files"

Author Message
kindnessHelps

Guest


Want to put folder of files with variable names with winscp. Have a script for a single file but would like to do a forfiles or loop to send files.

I have the below which isn't working.
FORFILES /m *.csv /c "C:\"Program Files (x86)"\WinSCP\WinSCP.com /command "option confirm off" "option batch abort" "open "Transfer"" "put ""c:\Files\@file""" "exit""
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
You have quotes all wrong.

But actually I was not able to make foreach refer to winscp.com in path with spaces.
Another issue that the foreach is broken when passing arguments to the command.
Even such a trivial command like this does not work:
forfiles /m *.csv /c "notepad.exe @file"
One have to run the command via cmd.exe to make it work properly.

So my final solution was:
FORFILES /m *.csv /c "cmd.exe /c c:\progra~2\winscp\WinSCP.com /command \"option confirm off\" \"option batch abort\" \"open Transfer\" \"put \"\"@file\"\"\" \"exit\""

But ANYWAY!
Why are you using foreach at all? WinSCP supports file masks too:
"C:\Program Files (x86)\WinSCP\WinSCP.com" /command "option confirm off" "option batch abort" "open "Transfer" "put ""c:\Files\*.csv""" "exit"
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License