Search code examples
ftpwinscp

How to exclude a subfolder from an FTP download when using WinSCP in a batch file that has spaces?


I am using a get function via WinSCP script to download new files from an FTP server but need to exclude a folder that has spaces. This is what I have but it's throwing an error:

get -filemask=|/Images/DO NOT USE/ -neweronly -resumesupport=on -resume "/FTP_FILES" "D:\FTP_Downloads"

Error:

Can't get attributes of file "NOT'.
Could not retrieve file information 
/NOT can't be listed

My guess is it's hanging on the fact that DO NOT USE folder has spaces. Unfortunately I have no access to rename this folder, and just simply want to ignore it when downloading. I tried adding quotations, didn't do anything, folder still was downloading.

How do I execute this properly?


Solution

    1. Wrap the file mask to double quotes, the way you already wrap the source and target paths.
    2. The path mask must match a complete path. You can solve that by prefixing the path with * or by using an absolute path.
    -filemask="|*/Images/DO NOT USE/"