Copying a Folder and renaming it using command prompt

[亡魂溺海] 提交于 2020-01-01 15:42:35

问题


I am trying to copy a folder and paste it in the same directory it was copied from.

For example

C:\Test is the main directory which consists of a folder ACDM, I would like to copy ACDM in the same directory and rename the new folder to ACDM1 which will have all the same files as ACDM has

I would like to do it using command prompt

I tried the following

C:>Xcopy C:\Test C:\Test\ACDM1 /E /U Cannot perform a cyclic copy 0 File(s) copied

which fails, not sure hoe to add REN command with XCOPY command.

Need help ASAP as i would want to create a batch file which will create a copy of an existing folder and rename it according to a name retrieved from a text file..


回答1:


xcopy "C:\Test\ACDM\*.*" "C:\Test\ACDM1\" /s/h/e/k/f/c



回答2:


for /f "delims=" %%a in (yourtextfilename) do xcopy "C:\Test\ACDM" "C:\Test\%%a\" /E

as a .bat file line. Directly from the prompt, change each %% to %

I've assumed (for lack of futher information) that your textfile contains just the one line

ACDM1
  • neither do you specify the textfilename tou want to use.



回答3:


 xcopy C:\Test\ACDM C:\Test\ACDM1\ /E /Q


来源:https://stackoverflow.com/questions/21791763/copying-a-folder-and-renaming-it-using-command-prompt

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