Automated moving of remote files in new folders matching the files' names

Advertisement

spawn
Joined:
Posts:
1
Location:
Berlin, Germany

Automated moving of remote files in new folders matching the files' names

Hello,

let's say I have a remote folder named manuals which contains the files 1.pdf, 2.pdf and so on. My goal is to let WinSCP move these files into new folders. The new folders need to be named like the file names without the file endings, resulting in:
folder file
1      1.pdf
2      2.pdf
3      3.pdf
...
manuals <empty> 
Moreover, each pdf file also has a corresponding .chk file in the manuals folder which should also be moved, so the real result should be

folder files
1      1.pdf, 1.chk
2      2.pdf, 2.chk
3      3.pdf, 3.chk
...
manuals <empty> 
How can I achieve this?

Thanks in advance!
Regards, spawn

Reply with quote

Advertisement

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

Re: Automated moving of remote files in new folders matching the files' names

There's no magical way in WinSCP to achieve this.
Either you would have to script it, e.g. in PowerShell with use of WinSCP .NET assembly. If you have a basic programming experience, it should not be difficult.

If not, another way to achieve this, is to grab list of all files in your folders and with some easy regex search and replace, convert that list to a set of WinSCP (or shell) mv commands.
Something like:
^(.*)\.\w+$ => mv $1/$0

Alternatively, there are definitely tools that can do this in GUI with local files (I use Renamer plugin of Altap Salamader file manager). So you can download all your files, do the renames/moves with the local files, and re-upload the files back.

Reply with quote

Advertisement

You can post new topics in this forum