Home How can I copy a file with a BATCH script from a folder on one drive to a folder of the same name on another drive?
Reply: 1

How can I copy a file with a BATCH script from a folder on one drive to a folder of the same name on another drive?

Mike Roh
1#
Mike Roh Published in 2018-02-14 04:49:20Z

I'd like to make a Batch script to copy hundreds of files to their proper directories. Having to do this several times I figured a script would be helpful in the future. The only problem is I don't know the filenames or the directories they're in, ok I mean I do, but there's hundreds of them so it's not going to help.

Basically, I have the images for the movies in c:\movies in their own folders, but the movies are all in f:\movies in folders of the same name for each movie. I want to get the images and the movies all together again.

Example:

copy c:\movies\%dir%\%img%.png F:\Movies\%dir%\%img%.png

Thanks in advance for your help!

Gerhard Barnard
2#
Gerhard Barnard Reply to 2018-02-14 06:53:52Z

It can be made more dynamic, but your requirement is pretty simple.

@echo off
for /f %%a in ('dir /b /a:d "c:\movies"') do (
 copy /Y "C:\movies\%%a\*.png" "F:\movies\%%a"
)
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.332141 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO