filemask for directories? workaround possible?

Advertisement

sd-guest
Guest

filemask for directories? workaround possible?

I'd like to transfer the content of a local folder with sub-folders to a remote server. Only folders created in 2020 year should go to a specific remote folder, e.g.:

Local:
folder1 (created 2019)
folder2 (created 2020)
Remote:
\all_folders_of_2020\folder2

I've tried a "synchronize" script with a specific file mask. This works in principle but creates empty folders on the remote site for the 2019 local folders.
I found out that a filemask for directories is not possible.
So I've written a powershell script with "session.PutFiles" and selecting folders with "Get-ChildItem" by date. This again, works in principle but transfers folders that have been already transferred in a previous session again. Here I'd need something like "-neweronly", which seems to be not possible in powershell scripts.
I guess it is possible to compare a list of folders from the remote site with a list of local folders and transfer only folders which are not present on the remote server. But before I start writing such a script for powershell I'd like to ask if there is a more convenient or easy way to achieve a folder selection. Something like a filemask for directories would help. Thanks you very much in advance for your answer!

Reply with quote

Advertisement

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

Re: filemask for directories? workaround possible?

It seems that you would be happy with selecting files (not folders) by the timestamp, what is possible, as you know.

To avoid creating the empty folders, use ExcludeEmptyDirectories raw transfer setting:
https://winscp.net/eng/docs/rawtransfersettings

Or use your PowerShell script, just replace Session.PutFiles with Session.SynchronizeDirectories(SynchronizationMode.Remote, ...)
https://winscp.net/eng/docs/library_session_synchronizedirectories
https://winscp.net/eng/docs/scriptcommand_put#net

Reply with quote

Advertisement

You can post new topics in this forum