Scripted file winscp.com method and files with embedded spaces

Advertisement

jpantera
Joined:
Posts:
23
Location:
Los Angeles, CA

Scripted file winscp.com method and files with embedded spaces

Hello Martin and WinSCP Support,

I'm trying to write an automation to pull a set of files, and the users generating those files seem to need to have an embedded space in the middle of them. Using winscp.com and a script file, this just doesn't work:

Try #1:
winscp> dir MyFile*
dir MyFile*
-rw-rwx---   1 <XXXXXXX> <XX>         6895612 Jul 11 16:06:49 2024 MyFile01 060924-063024.csv
-rw-rwx---   1 <XXXXXXX> <XX>         9325753 Jul 11 16:06:41 2024 MyFile02 060924-063024.csv
winscp> dir "MyFile01 060924-063024.csv"
dir "MyFile01 060924-063024.csv"
Error listing directory 'MyFile01 060924-063024.csv'.
No such file or directory.
Error code: 2
Error message from server: No such file
(A)bort, (R)etry, (S)kip: Abort
Try #2, other similar:
winscp> dir \"MyFile01 060924-063024.csv\""
dir \"MyFile01 060924-063024.csv\""
Error listing directory '\MyFile01 060924-063024.csv\"'.
No such file or directory.
Error code: 2
Error message from server: No such file
(A)bort, (R)etry, (S)kip: Abort
I know I've been able to escape the white spaces in the past by surrounding the file name, and path to the file with double-quotes, but that's not working with this site. I did write a wildcard type of script (to grab all files of this name in my get), that pulls more than the files I need to download down, and then I can ferret through them on my system, but can you please offer an example of how to handle this via winscp.com?

I do use Perl as my go-to language, and am able ot use Perl and the .NET Assembly to figure out the exact file names I need, but I'm unsure of the method with Perl and .NET Assembly to do the get on these files with these embedded spaces, so perhaps you could share that, as it's not show in documentation.

Thanks,
Joe P.

Reply with quote

Advertisement

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

Re: Scripted file winscp.com method and files with embedded spaces

It's not about the space. You cannot use dir (or ls actually) with a single file. With spaces or not.
Use stat command to retrieve information about a single file.
https://winscp.net/eng/docs/scriptcommand_stat

To download a file with WinSCP .NET assembly, use Session.GetFiles or other similar methods:
https://winscp.net/eng/docs/library_session_getfiles

Reply with quote

Advertisement

You can post new topics in this forum