Uploading single file (Whitespaces)

Advertisement

jxk7581
Joined:
Posts:
2

Uploading single file (Whitespaces)

I am attempting to integarte WinSCP into a larger project which will generate a Batch file to execute PGP and FTP commands. WinSCP will be used to execute single file transfer commands using the /command option (See https://winscp.net/eng/docs/script_upload_single_file)

The problem I have is in dealing with whitespaces in either the directory path or file name. Below is the single command line statement to send a file. Since both the Directory and File name contain whitespaces, I get the "File or folder xxxxx Does not Exist" error. I've tried many different options (Single Quotes, double quotes, Brackets) to enclose around the path & filename with no luck.

Your help is appreciated!!! :)

"C:\Program Files\WinSCP\winscp.com" skype@ftp.uppquad.com /command "option confirm off" "put Y:/UQ Feed/Encrypted/RISE GA-Net Units-Daily Report-MTD-20080430.csv.pgp /NAR/" "exit"

Reply with quote

Advertisement

jxk7581
Joined:
Posts:
2

jrynd wrote:

It's kind of hard to put everything on one command line.

You'd probably have more luck creating a command file (see https://winscp.net/eng/docs/scripting ). That way you could use quotes in the middle of each command.

Thanks for the suggestion.

I'm really trying to avoid that. I have a Database of all of the different files, FTP|SFTP sites, PGP Keys, folders, and destinations. A script reads from the DB to create a single batch file to execute gpg and winscp for each file or group of files. Using a command file would mean I would have to break up my single batch file into multiple file executions.

I DID have some luck :D reformatting folders and files from "C:\ABC DEFGHI\" to "C:\ABCDEF~1\" but I would have to write some formulas in my batch file creation to identify whitespaces and reformat any folders|files appropriately. I'm really hoping for a miracle here.

Reply with quote

jrynd
Joined:
Posts:
20
Location:
New York

jxk7581 wrote:

I have a Database of all of the different files, FTP|SFTP sites, PGP Keys, folders, and destinations. A script reads from the DB to create a single batch file to execute gpg and winscp for each file or group of files. Using a command file would mean I would have to break up my single batch file into multiple file executions.

You pass the command file you want to use as a parameter when you call winscp. Create the multiple command files and pass them in. You still only need one batch file.

And while I'm at it, why bother calling WinSCP multiple times? Just make one WinSCP command file that handles all the WinSCP stuff. It can connect to a server, do stuff, disconnect, and then connect to a different server.

jxk7581 wrote:

I DID have some luck :D reformatting folders and files from "C:\ABC DEFGHI\" to "C:\ABCDEF~1\"

Ever hear of dir /x filename ?

Reply with quote

Guest

The reason I am passing the command file multiple times is because each file will be going to a different FTP destination. I was trying to avoid creating multiple command files as these are actually being generated by a database query.

Your suggestion of one command file with multiple open, put, close commands would work. I could just keep the same .bat file to execute winscp on this dynamic command file. The only "down" side is I will have to have a separate DB query to generate my PGP Encryption .bat file. I'll let you know how it works.

Also, I have not heard of dir /x filename.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Your suggestion of one command file with multiple open, put, close commands would work. I could just keep the same .bat file to execute winscp on this dynamic command file. The only "down" side is I will have to have a separate DB query to generate my PGP Encryption .bat file. I'll let you know how it works.
WinSCP 4.1 supports using environment variables in script file. So you can have one script file and set its parameters in your batch file using the variables. See documentation.

As for your original question about spaces, see another documentation.

Reply with quote

Advertisement

You can post new topics in this forum