%1
是批量命令行参数。
所以使一批与这些线
Echo %1
Echo %2
然后请在命令提示符下
nameofbatch.bat Parameter1 "Parameter 2"
类型ftp /?
有关FTP的帮助。使用ftp -s:script
来执行一系列ftp命令。键入ftp
,然后键入?
获取脚本中命令的帮助。
您可以通过批量动态生成脚本来指定不同的文件名。 %1
将具有在命令行中指定的名称。
echo open ftp.microsoft.com >ftp.script
echo. >>ftp.script
echo user anonymous >>ftp.script
echo [email protected] >>ftp.script
echo ls >>ftp.script
echo get softlib\%1 >>ftp.script
ftp -s:ftp.script
所以运行上面的批处理像这样
nameofbatfile.bat readme.txt
你应该在命令提示符窗口中文件夹中的readme.txt文件。
下面是关于命令提示符的更多信息。查看报价条目。
& seperates commands on a line.
&& executes this command only if previous command's errorlevel is 0.
|| (not used above) executes this command only if previous command's errorlevel is NOT 0
> output to a file
>> append output to a file
< input from a file
| output of one command into the input of another command
^ escapes any of the above, including itself, if needed to be passed to a program
" parameters with spaces must be enclosed in quotes
+ used with copy to concatinate files. E.G. copy file1+file2 newfile
, used with copy to indicate missing parameters. This updates the files modified date. E.G. copy /b file1,,
%variablename% a inbuilt or user set environmental variable
!variablename! a user set environmental variable expanded at execution time, turned with SelLocal EnableDelayedExpansion command
%<number> (%1) the nth command line parameter passed to a batch file. %0 is the batchfile's name.
%* (%*) the entire command line.
%<a letter> or %%<a letter> (%A or %%A) the variable in a for loop. Single % sign at command prompt and double % sign in a batch file.
你到目前为止试过了什么? Google上有很多关于如何通过命令行FTP文件的例子。我们不太适合你的代码(好吧,有人可能,但他们真的不应该),但我们很乐意纠正你现有代码中的任何错误。还有什么意思是“动态接受文件名?” – SomethingDark 2015-04-05 03:16:17
嗨, 我从来没有做过的cmd文件。我是一个数据软件安装专业人员,而不是编码人员。 – 2015-04-05 04:09:37
动态接受文件名我的意思是 调用cmdfilehere inputfilenamehere.csv – 2015-04-05 04:13:10