Replacing a file into multiple folders/subdirectories

前端 未结 3 571
遥遥无期
遥遥无期 2020-12-31 05:30

Is there a way in command prompt to take one file and copy it into another folder and its subdirectories based on its name?

I have an image named 5.jpg that has been

3条回答
  •  情歌与酒
    2020-12-31 06:08

    I'm not sure if I understood you completely. The following code will search for all occurences of 5.jpg in subfolders of C:\MyPath\ and replaces them with C:\NewImage\5.jpg. I did test it, so it should work.

    FOR with parameter /R will help you here:

    FOR /R C:\MyPath\ %%I IN (5.jpg) DO COPY /Y C:\NewImage\5.jpg %%~fI
    

    If you want more information about what FOR /R does and what %%~fI means, have a look at FOR /? | more which gives nice explanations about the new Windows cmd possibilities that are used here.

提交回复
热议问题