It appears that it is not possible to append a dotted text string to the end of a file name without the loss of the text to the right of the last period in the file name when downloading files using any one of the following get commands:
# test A
get * *.dl
# test B
get * *.*.dl
The issue became apparent when a series of files were uploaded with the same file name to the left of the last period with a unique numeric value to the right of the last period. As it is necessary to overwrite the destination file when the uploader wants to update the file previously uploaded, the script option “option confirm off” is included in the ftp script.
For example give the following list of files to download:
test1.xyz.12345
test1.xyz.54321
test1.xyz.98765
When we download using test A syntax, the file name “extension” is lost and the downloaded results are a single file:
With the loss of the unique value to the right of the last period, the ftp script downloads and overwrites the previous downloaded file leaving a single file in destination folder.
A workaround is to use a hyphen in place of the dot for the appended text string. Here is the syntax for test C:
When we download using test C syntax, we get all the files downloaded to the destination folder. Here are the results of this download:
test1.xyz.12345-dl
test1.xyz.54321-dl
test1.xyz.98765-dl
So it appears that there is no way to append a dotted text value to the end of the downloaded file name where there are one or more periods in the original file name without losing the text to the right of the last period.
The documentation for the Operation Mask (
https://winscp.net/eng/docs/operation_mask) states:
WinSCP by default offers you operation mask *.* that leaves filename as is.
Test B refutes this claim when attempting to append a dotted text value to a file name.
In summary, file names are no longer limited to 8x3 nomenclature and as I have no control over what others upload, I feel there should be a way for WinSCP.com to append dotted text values without the loss of what formally was known as the file “extension”. Maybe in a future release, there can be an option to toggle the option mask mode as either “regular expressions” or ”masking tool”. Adding the option for regular expressions would solve the problem and open the door to new ways of manipulating the destination file name.
WinSCP Version: 5.15.4
Platforms tested: Server 2012 R2, Windows 10, Windows 7, and Windows XP
Transfer Protocol: sFTP via scripted WinSCP.com
Here is the command line:
"c:\Program Files\WinSCP\WinSCP.com" /script=test.script /parameter // c:\tmp >c:\tmp\LogFile.log
Here is the script:
option batch abort
option confirm off
open "test FTP site"
cd "/var/tmp/WinSFTP Test"
lcd "c:\tmp\WinSFTP Test"
dir
# test A
get * *.dl
# test B
get * *.*.dl
# test C
get * *-dl
close
exit
Here is the output from the command:
batch abort
confirm off
In scripting you should not rely on saved sites, use this command instead:
open [snip]
Searching for host...
Connecting to host...
Authenticating...
Using username "root".
Authenticating with [snip]
Authenticated.
Starting the session...
Session started.
Active session: [snip]
/var/tmp/WinSFTP Test
c:\tmp\WinSFTP Test
-rw-r--r-- 1 root root 135 Sep 24 17:00:03 2019 test1.xyz.12345
-rw-r--r-- 1 root root 15 Sep 24 16:35:45 2019 test1.xyz.54321
-rw-r--r-- 1 root root 10 Sep 25 16:38:23 2019 test1.xyz.98765
test1.xyz.12345 | 135 B | 0.0 KB/s | binary | 100%
test1.xyz.54321 | 15 B | 0.1 KB/s | binary | 100%
test1.xyz.98765 | 10 B | 0.1 KB/s | binary | 100%
test1.xyz.12345 | 135 B | 0.0 KB/s | binary | 100%
test1.xyz.54321 | 15 B | 0.1 KB/s | binary | 100%
test1.xyz.98765 | 10 B | 0.1 KB/s | binary | 100%
test1.xyz.12345 | 135 B | 0.0 KB/s | binary | 100%
test1.xyz.54321 | 15 B | 0.1 KB/s | binary | 100%
test1.xyz.98765 | 10 B | 0.1 KB/s | binary | 100%
Session [snip] closed.
No session.