How to limit "move" command

Advertisement

MrBedo
Joined:
Posts:
1

How to limit "move" command

I am trying to move some remote folders into a remote archive. The issue here is I need to exclude certain folders. From what I have read and what I have tried, it seems there's no easy way to exclude folders when using the move command.
Specifying the folders to move by name isn't an option as they are random and change each day.

So I have a bunch of root folders:

RandomFolder A
RandomFolder B
RandomFolder C
Archive 1
Archive 2

How can I move all the RandomFolders into Archive 1 and leave Archive 2 where it is?

I have read around but can't seem to find a definitive answer. There was talk of adding exclusion options to the mv command some time ago, but that seems not to have happened yet.

Thanks

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
33,846
Location:
Prague, Czechia

Re: How to limit "move" command

If the folders you want to move have anything in common (like RandomFolder prefix), you can use a file mask:
mv /RandomFolder* /destination/path

If not, you can write a code in your favourite language with use of WinSCP .NET assembly and its Session.EnumerateRemoteFiles (or Session.ListDirectory) and Session.MoveFile methods.
https://winscp.net/eng/docs/library_session_enumerateremotefiles
https://winscp.net/eng/docs/library_session_movefile

Here is a example that you can start with:
https://winscp.net/eng/docs/library_example_advanced_rename

Reply with quote

Advertisement

You can post new topics in this forum