How to copy MP3 files existing in seperate source directories into 1 target directory? I have WIndows XP on my PC.

zimmer9
zimmer9 used Ask the Experts™
on
Is there a DOS command I can issue to copy MP3 files existing in seperate source directories into 1 target directory ? I have WIndows XP on my PC.

I have directories with names that all start out with
D:\MyDocuments Are Here\My Musci\Something-newest\:

For example:

D:\MyDocuments Are Here\My Musci\Something-newest\3 Doors Down\Away From The Sun\

D:\MyDocuments Are Here\My Musci\Something-newest\Usher\Raymond vs Raymond\

D:\MyDocuments Are Here\My Musci\Something-newest\Usher\Unknown Album\

D:\MyDocuments Are Here\My Musci\Something-newest\Usher\New James.net\

D:\MyDocuments Are Here\My Musci\Something-newest\The Zombies\Unkonw Album\

And within each of these directory paths are files with an extension of "MP3".

Do you know how to copy ALL of the fiiles with an extension of "MP3" from within all folders
that start with the directory name of "D:\MyDocuments Are Here\My Musci\Something-newest\":
to a new folder titled C:\Something\

For example:
Copy D:\MyDocuments Are Here\My Musci\Something-newest\:The Zombies\Unknown Album\Time of the Season.mp3
Copy D:\MyDocuments Are Here\My Musci\Something-newest\:The Zombies\Unknown Album\She's Not There.mp3


to:
C:\Something\Time of the Season.mp3
C:\Something\She's Not There.mp3




Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Test your restores, not your backups...
Top Expert 2016
Commented:
At a DOS command prompt you can do:

for /R "D:\MyDocuments Are Here\My Musci\Something-newest" %A in (*.mp3) do copy "%~A" "C:\Something"

Open in new window

if you want to do it in a BAT file then something like this would work:

@echo off
set BaseDir=D:\MyDocuments Are Here\My Musci\Something-newest
set DestDir=C:\Something
for /R "%BaseDir%" %%A in (*.mp3) do copy "%%~A" "%DestDir%"

Open in new window

~bp
AnilData Manager

Commented:
The base folder is the same so use xcopy


xcopy D:\MyDocuments Are Here\My Musci\Something-newest\*.mp3   C:\Something\       /s

Not tested but should work.

A>
Bill PrewTest your restores, not your backups...
Top Expert 2016

Commented:
XCOPY will preserve the directory structure, rather than flatten it all down to a single folder, as was requested.

~bp
AnilData Manager

Commented:
Cool.Missed that one.  Then watch out for duplicates if any.

zimmer9 : Did you want to preserve your subflder structure or not ?

Author

Commented:
I would keep the existing subfolder structure until I can verfiy that the mass copy was performed correctly and then afterwards, I wish to delete the existing subfolder structure.

WHich leads to another question:

How would I delete the subfolders within D:\MyDocuments Are Here\My Musci\Something-newest\:
after I have verified that all files were successfully copied?

Bill PrewTest your restores, not your backups...
Top Expert 2016

Commented:
==> How would I delete the subfolders within D:\MyDocuments Are Here\My Musci\Something-newest
==> after I have verified that all files were successfully copied?

I think a typical approach to this would be to run a similar recursive script approach that drills into each of the original folders, this time deleting any MP3 files, and checking each folder containing MP3 files to see if it becomes empty.  If it does, we remove that folder.

Could be done in DOS, but would be a lot smaller script if you were open to a VBS solution?

~bp

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial