Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Can anyone help on this.

I have mp3 files all over the shop and therefore a lot of duplicates.

What i need is a command line function that will move all files of type mp3 to a new folder. I'm not worried if the files structure on the new folder is retained or not.

I could easily copy using copy c:*.mp3 /s c:\mp3 for example, but due to the amount of files i have i would run out of disk space copying them, hence the need to move.

Thanks

share|improve this question
add comment

4 Answers

As executed from command line:

for /r %M in (*.mp3) do @if /I "%~dpM" neq "c:\temp\mp3 files\" @echo move /-Y "%M" "c:\temp\mp3 files\"

This simply echoes commands to the screen so it's safe to run and see if it fits your needs. It will start from current directory, so if you want enumerate everything exec it from c:\.
Naming of your destination directory is of course up to you - but make sure if exists! You may also want to put it in a variable, or as batch parameter to avoid typing mistakes. When you're 100% sure output is correct just remove @echo, and then test it again with few files/paths (make sure to include those with spaces and some unusual chars)

Few words of caution:
1. You said you you have dups. I've put /-Y as a safeguard, so moving a file with the same name as already moved will stop this script waiting for you to confirm. You may overwrite this with /Y switch, but you risk overwriting more than you wished for!
2. This is hardly reversible or irreversible (if you have 'false' duplicates - different files with same name) operation. Make a backup before you start!
3. Look what you have before you move - this will give you a list of all of your mp3s, nicely formatted with name, size and directory:
for /r %M in (*.mp3) do @echo "%~nxM", "%~zM", "%~dpM" >>filelist.txt
Use spreadsheet to sort and inspect it.

Notes:
a) In fact you could remove that if part altogether, as moving a file onto itself does noting, but I just find it messy :-)
b) if you want to put it in a batch replace single %with double %%

share|improve this answer
add comment

Try this command from top level folder where you have mp3 files.

forfiles /S /M *.mp3 /C "cmd /c move @file C:\music"    

Note that if you have files with duplicate names, moving all of them into a single folder is not the right thing to do. It will cause data loss.

share|improve this answer
add comment

I assume this is for backing up or similar. If so, I made a bat file and Scheduled tasks runs it once a week.

Try making a bat file.

Open notepad and type

xcopy "file location" "file destination" /i /e /y /z

eg

xcopy "c:\allmusic\mp3\" "e:\music\" /i /e /y /z

Save the file as .bat (eg "copyFiles.bat")

You can have multiple lines but one per line. EG

xcopy "c:\allmusic\mp3\" "e:\music\" /i /e /y /z
xcopy "c:\allmusic\wav\" "e:\music\" /i /e /y /z
xcopy "c:\allmusic\wmv\" "e:\music\" /i /e /y /z

Please note, the /i /y /e and /z have meanings which may be desirable or not (such as overwriting), see a list here:

/A Copies only files with the archive attribute set, doesn't change the attribute.  
/M Copies only files with the archive attribute set, turns off the archive attribute.  
/D:m-d-y Copies files changed on or after the specified date. If no date is given, copies only those files whose source time is newer than the destination time.  
/EXCLUDE:file1[+file2][+file3]... Specifies a list of files containing strings. When any of the strings match any part of the absolute path of the file to be copied, that file will be excluded from being copied. For example, specifying a string like \obj\ or .obj will exclude all files underneath the directory obj or all files with the .obj extension respectively.  
/P Prompts you before creating each destination file.  
/S Copies directories and subdirectories except empty ones.  
/E Copies directories and subdirectories, including empty ones. Same as /S /E. May be used to modify /T.  
/V Verifies each new file.  
/W Prompts you to press a key before copying.  
/C Continues copying even if errors occur.  
/I If destination does not exist and copying more than one file, assumes that destination must be a directory.  
/Q Does not display file names while copying.  
/F Displays full source and destination file names while copying.  
/L Displays files that would be copied.  
/H Copies hidden and system files also.  
/R Overwrites read-only files.  
/T Creates directory structure, but does not copy files. Does not include empty  directories or subdirectories. /T /E includes empty directories and subdirectories.  
/U Copies only files that already exist in destination.  
/K Copies attributes. Normal Xcopy will reset read-only attribute  
/N Copies using the generated short names.  
/O Copies file ownership and ACL information.  
/X Copies file audit settings (implies /O).  
/Y Suppresses prompting to confirm you want to overwrite an existing destination file.  
/-Y Causes prompting to confirm you want to overwrite an existing destination file.  
/Z Copies networked files in restartable mode.   

You can also use "move" which is similar to cut and paste

eg

move "source" "destination"

move "c:\allmusic\mp3\" "e:\music\" /i /e /y /z
move "c:\allmusic\wav\" "e:\music\" /i /e /y /z
move "c:\allmusic\wmv\" "e:\music\" /i /e /y /z

EDIT

To copy various folders by looping through, try

for /f %%f in ('dir /b c:\')  do (
cd\
cd %%f
copy *.mp3 "e:\music"

for /f %%g in ('dir /b %%f')  do (
cd\
cd %%g
copy *.mp3 "e:\music"


for /f %%h in ('dir /b %%g')  do (
cd\
cd %%h
copy *.mp3 "e:\music"
pause
)
)
)

Note, this does 3 levels of subfolders

share|improve this answer
    
It's to rearrange rather than backup. so all on the same drive at the moment, so no room to copy hence the requirement to move ( full backup will be done once i have them all in a sensible location. Thanks –  Derek Aug 6 '12 at 11:46
    
Then use 'move' to do what you need (see my original post at the bottom) –  Dave Rook Aug 6 '12 at 11:48
    
the problem is i have them all over the place so would like a move function that will search all sub folders from root C: and then move them to a folder. rather than searching and then moving folders individually, as this could take days!. –  Derek Aug 6 '12 at 11:53
    
I updated my answer: If you're asking for a program which will first search your PC for a certain file type (MP3), and then copy them to one place then I suggest running a search for the file extension in Windows and from here selecting all (control +A) and cutting/copying and pasting? Or will this occur regularly? –  Dave Rook Aug 6 '12 at 11:55
    
the problem with using explorer, is the time, I've tried it and with the volume of files i have it's just hangs right clicking on the file list after searching. hence the requirement for a dos command –  Derek Aug 6 '12 at 12:34
add comment

If it doesn't need to be a command-line operation, then you can simply use the file explorer search box. Open C:, search for *.mp3, pressCtrl+A and move the files. You'll be asked about duplicates.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.