Prompt Windows - Script

2019-06-14 01:10发布

I have a folder (essa é nova pasta) with multiple .txt files in it

C:\xml\UPLOAD\essa é nova pasta\35160101660296000130550020000540011858610314.txt

The folder is a name that has accent (essa é a nova pasta) and made a script to generate a list of all the .txt files, but looked like this:

C:\xml\UPLOAD\essa ‚ nova pasta\35160101660296000130550020000540011858610314.txt.

I need to create an FTP script to make a put to from the list of .txt files. generated above. I used the FOR command and begot the list but it came out like this:

user
password
put "C:\xml\UPLOAD\essa ‚ nova pasta\35160101660296000130550020000540011858610314.txt" /content/UPLOAD/35160101660296000130550020000540011858610314.txt
bye

He gave a message that the file does not exist, because it does not recognize the name of the folder (essa ‚ nova pasta)

I need my FTP script exit as the folder name "this is new folder", ie, with the correct name and manages my FTP script correctly as follows:

user
password
put "C:\xml\UPLOAD\essa é nova pasta\ 35160101660296000130550020000540011858610314.txt" /content/UPLOAD/35160101660296000130550020000540011858610314.txt
bye

How do I solve this problem?

标签: windows cmd ftp
1条回答
成全新的幸福
2楼-- · 2019-06-14 01:32

If all your files come from "C:\xml\UPLOAD\essa é nova pasta\" then you can (once, at the top) run

lcd "C:\xml\UPLOAD\essa é nova pasta\

That way you're not manipulating the accented character in a for loop.

Then your put statements will look like this:

put 35160101660296000130550020000540011858610314.txt /content/UPLOAD/35160101660296000130550020000540011858610314.txt

If all your files need to end up in the remote directory /content/UPLOAD/ then you can further simplify by changing to that directory in the ftp command like this:

cd /content/UPLOAD

Then your put statement looks like this:

put 35160101660296000130550020000540011858610314.txt

You don't need to specify the filename twice that way. So to transfer these files:

C:\xml\UPLOAD\essa é nova pasta\35160101660296000130550020000540011858610314.txt
C:\xml\UPLOAD\essa é nova pasta\anotherfile.txt
C:\xml\UPLOAD\essa é nova pasta\yetanotherfile.txt
C:\xml\UPLOAD\essa é nova pasta\onemorefile.txt

to the remote server's directory /content/UPLOAD:

user
password
lcd "C:\xml\UPLOAD\essa é nova pasta\"
cd /content/UPLOAD
put 35160101660296000130550020000540011858610314.txt
put anotherfile.txt
put yetanotherfile.txt
put onemorefile.txt
bye
查看更多
登录 后发表回答