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

Author Message


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\ /command "option confirm off" "option batch abort" "open "Transfer"" "put ""c:\Files\@file""" "exit""
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 27106
Location: Prague, Czechia
You have quotes all wrong.

But actually I was not able to make foreach refer to 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\ /command \"option confirm off\" \"option batch abort\" \"open Transfer\" \"put \"\"@file\"\"\" \"exit\""

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

You can post new topics in this forum


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!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License