Batch script file name

故事扮演 提交于 2019-12-13 04:21:24

问题


I am using the below batch script to copy the files from current folder to the specified location.

 @echo off
 echo copying files to destination
 copy *.eps* \\10.10.14.13\adman\in\displ )

I am facing 2 problems in the above script.

  1. I am not able to select a particular file and run the script, for e.g if the folder got more (eps) files it copies all the files to the location.

  2. I want to insert my user login name at the end of the each copied file.

My file name look like F0#CGDBANG000947532#.eps and I want like this F0#CGDBANG000947532#username.eps.


回答1:


copy "*.eps*" "\\10.10.14.13\adman\in\displ\*%username%.*"

Try ForFiles /?, For /?, xcopy /?, and robocopy /? for how to select files on different critera.




回答2:


finally, after some of your comments here and in your other question, I understood your request (I think).

@echo off
for %%i in (%*) do if /i "%%~xi"==".eps" copy "%%i" "\\10.10.14.13\adman\in\displ\%%~ni%username%.%%~xi"
pause


来源:https://stackoverflow.com/questions/23847967/batch-script-file-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!