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

Advertisement

kindnessHelps
Guest

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

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""

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,518
Location:
Prague, Czechia

Re: forfile with winscp not working-Need to put folder of files

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"

Reply with quote

Advertisement

You can post new topics in this forum