Exclude files starting with a specific name

Advertisement

natchiram
Joined:
Posts:
8

Exclude files starting with a specific name

Hello guys,

I am trying a script to download all the files generated today but exclude the files that start with "temp". I am able to get all the files today using the filemask

get -filemask=*>=today but I am not sure how to add exclude file mask to leave the files that start with "temp"

I tried get -filemask=*>=today | temp* and some other variations but not getting any success. I am missing something but not sure what. Any suggestions?

Regards,
Ram

Reply with quote

Advertisement

natchiram
Joined:
Posts:
8

Re: Exclude files starting with a specific name

martin wrote:

No spaces (or wrap the mask to quotes):
get -filemask=*>=today|temp*

Thanks for your reply. Without wrapping the filemask, the script wouldn't even run but with wrapping, I am getting this error "Missing parameter for command 'get'"

Reply with quote

natchiram
Joined:
Posts:
8

Re: Exclude files starting with a specific name

WinSCP version that I am using is 5.17.5 Build 10414

This is the code that I am using

@echo off
 
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="C:\Users\username\Documents\WinSCP\WinSCP.log" /ini=nul ^
  /command ^
    "open ftp://server details/ -rawsettings ProxyPort=0" ^
    "cd /folder" ^
    "lcd \\path" ^
     get -filemask=*>=today|temp*
    "exit"
 
set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)
 
exit /b %WINSCP_RESULT%

Reply with quote

Advertisement

natchiram
Joined:
Posts:
8

Re: Exclude files starting with a specific name

martin wrote:

You didn't mention batch file until now.

It should be like this then:
     "get -filemask=*>=today|temp*" ^
Or:
     "get -filemask=""*>=today | temp*""" ^
See:
https://winscp.net/eng/docs/faq_batch_file#quotes
https://winscp.net/eng/docs/faq_batch_file#newline_escaping

Sorry, I should have mentioned that. Thanks for your suggestions and tried both the variations with same result but your second link on "New-line Escaping" has "get *" ^ in the example. So I tried "get -filemask=*>=today|temp* *" ^ and it finally worked. Thanks for pointing me in the right direction.

Reply with quote

Advertisement

You can post new topics in this forum