Print Shortlink

DOS Still Useful

Ever had this need to copy or move files from multiple subfolders to another folder? For example, if you have many subfolder under Pictures and you want to copy all video files to another folder just for videos? The Windows procedure for this easy but lengthy; you will have to use the Search box at the top right and type *.avi (for example) and then use Ctrl+A to select all files and then Ctrl+X/Ctrl+C to cut/copy and then go to the destination folder and use Ctrl+V to paste the files.

Well, there is an easy way, i.e. if you don’t mind getting your hands dirty with a ‘little’ DOS programming. Try this:
1. Open Notepad.
2. Type in the following code
   for /R %f in (sourcefolder\*) do (
      pushd %f
      command .\filter destinationfolder
3. You will need to replace the following with your own settings:
     sourcefolder = the folder from which you want to move/copy files
     command = move (for moving files)
                        copy (for copying files)
     filter = for selecting multiple files (e.g. *.avi or *.jpg)
     destinationfolder = the folder where you want to move/copy files
4. Save the file with .bat extension (e.g. Moving.bat)
5. Double click the file and voila!

     for /R %f (E:\Documents\*) do (
        pushd %f
        move .\*.docx E:\Backups

The above example will check all folders under the E:\Documents folder and move all Word documents to E:\Backups folder. You can create multiple files like this with different filters and save them with appropriate names (e.g MoveJPG.bat, MoveDocs.bat, MoveAVI.bat etc.)

The only problem with this approach is that it will not handle duplicate file names.