Could anyone write a batch/vbs script for me? - File renaming and moving.

Associate
Joined
27 Dec 2008
Posts
309
All it needs to do is take the folder name, rename the video file inside to the name taken from the folder, then move the file to a directory above and then delete the original folder the name come from.

At the moment the folder structure is like this:

~\Videos\TV Shows\The Inbetweeners\Season 2\Ep01. The Field Trip\The Field Trip.avi

Because I'm going to be using VMC along with MetaBrowser and MediaBrowser I need the structure to be like this:

~\Videos\TV Shows\The Inbetweeners\Season 2\Ep01. The Field Trip.avi

If anyone could write the script I'd greatly appreciate it, or else it would mean renaming over 600 files,

Thanks.
 
I tried to do this using cmd.exe, but I felt one of my headaches coming on, so I cheated and used JPSoft's Take Command Console LE. For those who don't know, it's basically a command processor on steroids, and the direct descendent of 4DOS for those old enough to remember it. It has some interesting variable functions which simplify things in comparison to cmd.exe (yes, I'm sad).

If you want to give it a shot, download and install TCC LE (the freeware console version), then use it to run the following script as a .BAT or .BTM file:

@Echo off
cdd C:\Videos

REM Recursively rename all AVI files based on pathname (%@LEFT variable removes trailing backslash)
for /r %a in ("*.avi") do ren "%a" "%@LEFT[-1,%@path[%a]].avi"

REM Delete empty folders with same name as AVI files (ignoring .avi extension)
for /r %a in ("*.avi") do rmdir "%@NAME[%a]"


You need to replace C:\Videos with the name of root folder of your video collection, and it's a quick'n'dirty script with no error checking, so if your folder structure is at all different from the way you outlined, the results could be unpredictable. :)
 
Back
Top Bottom