Windows – Move all files of type to a new folder in windows 7

command linefile managementfile-transferwindows

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

Best Answer

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

forfiles /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.

There is also a way to move all files matching the criteria inside of the sub directories with the /S flag:

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

This will recursively search through all the folders in your current directory

Reference: Forfiles windows command