Post a reply

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: Ability to use wildcards in remote/local path when scripting synchronization

How do you imagine this should work? Should WinSCP look for the first folder matching the mask? Or fail if there are more folders matching the mask? Should it work recursively (with possibility of having mask in any level of the path)?

No matter how complex I implement this, it won't be enough :)

Btw, it's easy to implement this using WinSCP .NET assembly and PowerShell.
krentmeister

Ability to use wildcards in remote/local path when scripting synchronization

I have a script I use to automate the synchronization of a remote folder.

The name of this folder changes based on the delivery date of the data. So each month the date suffix at the end of the directory changes. Currently below is the batch script I use to synchronize:
@echo off
 
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="\\SERVER\Geochem\Alberta Energy Regulator\REPS Compilation\SYNC_LOGS\REPSCD_Sync_!Y_!M.log" /ini=nul ^
  /command ^
    "open sftp://ACCOUNTNAME:PA$$W0RD@datasubscriptions.eub.gov.ab.ca/ -hostkey=""ssh-rsa 2048 REeK/HGvi9iVUxPd0zgVXtlEMgkumbjAaosOht5JbRg"" -rawsettings FSProtocol=2" ^
    "synchronize local ""\\s-cal-nas8\Geochem\Alberta Energy Regulator\REPS Compilation"" ""/REPS Reports_""%%TIMESTAMP-30D#yyyy_mm%%" ^
    "exit"
 
set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)

The timestamp has been working just fine for the most part, however the format of the date suffix can change slightly with each data release. As in, a - becomes a _ and vice versa.

Ideally the data provider would be consistent in their directory name format but if I could use a wildcard in the path of my synchronization like:
""/REPS Reports""*"

I would be fine as the name before the date never changes.
I've looked online and it appears to be a fairly requested feature and attempting to make it work by other means seems unnecessarily difficult. Please consider adding as a function, thank you.