Search This Blog

Wednesday 16 June 2010

Windows bulk rename and move files

FOR %v IN ("ken*.aif") DO MD TEMP&MOVE "%v" TEMP&REN TEMP "%v"
The FOR command takes every file matching the file specification "ken*.aif" and runs the command line following DO, swapping each filename for the variable %v. You can string multiple commands together on a single line by separating them with an ampersand (&)—handy! For each file, then, we create a folder named TEMP, move the file into that folder, and then rename the folder to the file's original name. This two-step process is needed because you can't have a file and an identically named folder in the same location.
Now, you said you want the folder to have the same name as the file. But maybe what you really want is not the file's whole name—you just want the filename portion without an extension. In that case a simple command will do the job:
FOR %v IN ("ken*.aif") DO MD "%~nv"&MOVE "%v" "%~nv" Here we've used %~nv instead of %v. This is a special code that tells the FOR command we just want the filename, not the extension.

Also, to rename using wildcards - REN *Page* *Page*.jpg

http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/Q_21873735.html