loop through folder to put files in different folders on FTPserver

Advertisement

HylkeD
Joined:
Posts:
1

loop through folder to put files in different folders on FTPserver

Hi,

Currently i'm using a script to put files on a ftpserver, I'm using this script as a scheduled task.

I have multiple .zip files that i put on the root folder of the ftpserver.
My recipient have asked me to change this method.

The ftpserver has got subfolders with the same name as a the files i'm putting there.
My recipient have asked me to put the files in the corresponding subfolder.

Is there a way to loop through the localfolder and put the files in a same-named subfolder?

I was thinking about:
.bat
D:\apps\WinSCP\WinSCP.com /log="D:\Scripts\Logs\WinScp\WinScpCogix%DATE%.log" /ini=nul /script="D:\Scripts\Cogix\28\WinSCPscriptCogix2.txt" /parameter %1

ren %1 *.zip

rem forfiles /P "D:\Script\Logs\WinScp" /S /M *.* /D -30 /C "cmd /c del @path"
EXIT %ERRORLEVEL%

.txt
open sftp://user:Password@ftp.server.nl/ -hostkey="ssh-rsa ......." -rawsettings FSProtocol=2

# Upload file

lcd D:\Export\Cogix\28
cd \%1%

Put %1%

exit

Respons in Logfile:
* 2018-05-01 12:33:24.881 (ECommand) Error changing directory to '\%1%'.
* 2018-05-01 12:33:24.881 Cannot get real path for '/\%1%'.
* 2018-05-01 12:33:24.881 No such file or directory.
* 2018-05-01 12:33:24.881 Error code: 2
* 2018-05-01 12:33:24.881 Error message from server ( Error: No such file or directory): Error: No such file or directory
< 2018-05-01 12:33:24.881 Script: Error changing directory to '\%1%'.
< 2018-05-01 12:33:24.881 Cannot get real path for '/\%1%'.
< 2018-05-01 12:33:24.881 No such file or directory.
< 2018-05-01 12:33:24.881 Error code: 2
< 2018-05-01 12:33:24.881 Error message from server ( Error: No such file or directory): Error: No such file or directory
< 2018-05-01 12:33:24.881 Script: /

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,603
Location:
Prague, Czechia

Re: loop through folder to put files in different folders on FTPserver

You WinSCP script seems ok, but you batch file not make any attempt to loop the files.

It should do something like:
forfiles /c "D:\...\winscp.com /log=... /ini=nul /script=... /parameter @file"

Reply with quote

Advertisement

You can post new topics in this forum