Script Problem with Get and Filemask

Advertisement

jdg
Joined:
Posts:
4

Script Problem with Get and Filemask

I have a script file that has been working great as long as I am simply using a wildcard to get all of the files from a directory and placing them in the directory I specify. For my examples, assume the source directory contains two files: fileabc.zip and filexyz.zip My command looks like the following:
get *.zip "X:\Output\"
(X:\Output is simply a local directory on my computer.)

Now, I need to modify this to use a -filemask switch so I can exclude one of the files. I have tried numerous methods of writing the "get" command and I always get an error saying:
Can't get attributes of file 'X:\Output',
No such file or directory.
Error code: 2

Here is a (failing) example of what I have tried:
get -filemask=filea*.zip|filex* "X:\Output\"

Just for further clarification, here is what my entire script looks like:
option batch abort
option confirm off
open sftp://<connection info>
cd /public/mydir
get -filemask=filea*.zip|filex* "X:\Output\"
exit

I am only showing one example of what I have tried. Believe me, I have setup the command, and the script, in multiple forms, using ideas I have been finding on this forum, but with no luck. Can anyone tell me why I cannot get this to work?

Reply with quote

Advertisement

jdg
Joined:
Posts:
4

In case anyone reads this, I want to mention that I found my issue. This was my original "get" command:
get -filemask=filea*.zip|filex* "X:\Output\"
I was missing my source argument. So, my working command looks like the following:
get -filemask=filea*.zip|filex* *.zip "X:\Output\"

Reply with quote

jdg
Joined:
Posts:
4

You are correct, for the example data I gave. I didn't spend enough time to properly demonstrate the files that were in the source. Instead of two files, my source actually has numerous files and I need to exclude only one of them. So, this might be a better example:

Assume my source directory contains multiple files, such as:
filea1.zip, filea2.zip, filea3.zip, fileb1.zip, fileb2.zip, fileb3.zip . . . filez1.zip, filez2.zip, filez3.zip

Now, I only want to exclude all files that end in "2". To do that, my get command would look like the following:
get -filemask=*.zip|*2.zip *.zip "X:\Output\"

Reply with quote

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

OK, but still, the *.zip in the -filemask redundant. It's enough to do:
get -filemask=|*2.zip *.zip "X:\Output\"
Or
get -filemask=*.zip|*2.zip ./ "X:\Output\"

Reply with quote

Advertisement

jdg

Thanks for the input. I simply didn't realize I could put just the exception in the -filemask criteria (your first example).
In your second example, does the ./ simply mean all files in the current directory? I just wanted to confirm because, again, I was not familiar with this type of syntax.

Reply with quote

martin
Site Admin
martin avatar

Yes, the * mask and the current directory are implicit, but the source parameter must be specified. So ./, * and ./* all mean the same.

Reply with quote

Advertisement

You can post new topics in this forum