Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: move remote files with different extension to a folder and create it if not exist.

cipo80 wrote:

I've understand the option batch continue if the directory already exist, and the mkdir, but I don't understand the last two commands option batch abort and stat foldername.

With option batch continue the mkdir would succeed, even if it failed to create a (non-existent) directory. stat foldername (in abort mode) fails, if the folder/file does not exist. So it's a way to abort the script, if it failed to create the folder.
See also https://winscp.net/eng/docs/script_checking_file_existence#scripting
cipo80

Re: move remote files with different extension to a folder and create it if not exist.

martin wrote:

The mv *.* /out/scaricati/*.* should work in general.
The problem is probably the scaricati subfolder, as the the *.* matches even the subfolders. So the command is trying to move /out/scaricati to /out/scaricati/scaricati, what is obviously not possible. In such scenario, your solution is the best you can do.


Thank you Martin for the reply, I've another doubt, I'm not sure if the remote service delete the "scaricati" folder or not and I need it before moving files.
After some google-searches I've found an old post with the same scenario and I've added four commands rows before files moving.
I've understand the option batch continue if the directory already exist, and the mkdir, but I don't understand the last two commands option batch abort and stat foldername.

open sftp://xxx:xxx@xxx:8022/ -hostkey="xxxxxxx="

cd /out
lcd "E:\report"
get *.pdf -filemask=/scaricati/

option batch continue
mkdir scaricati
option batch abort
stat scaricati

mv *.pdf /out/scaricati/*.pdf
mv *.xml /out/scaricati/*.xml

exit


Thanks in advance and have a great w.end!
martin

Re: move remote files with different extension

The mv *.* /out/scaricati/*.* should work in general.
The problem is probably the scaricati subfolder, as the the *.* matches even the subfolders. So the command is trying to move /out/scaricati to /out/scaricati/scaricati, what is obviously not possible. In such scenario, your solution is the best you can do.
cipo80

move remote files with different extension

Hi All, I've build this simple script to get only .pdf from a remote SFTP, then move the pdf's and .xml to the remote directory "scaricati".
I've try with mv *.* /out/scaricati/*.* but isn't working, I've try splitting the two mv command and it's working.

Isn't important, but is it possible to move all files extension with one command?


Thanks in advance

open sftp://xxx:xxx@xxx:8022/ -hostkey="xxxxxxx="


cd /out

lcd "E:\report"

get *.pdf -filemask=/scaricati/

mv *.pdf /out/scaricati/*.pdf
mv *.xml /out/scaricati/*.xml

exit