Labels

Wednesday, 20 March 2013

Batch Based File/Folder Creation

You have a lot of movies in different genre folders and you want to  create a folder for each movie in the same genre folder as where the movie is.
The code run a batch file from the parent folder Movies, scan for all *.mkv *.avi *.mp4 files in the genre folders and create folders based on the movie names. The name of the folders should be:

if you want the folder will end with Moviename.movie .(moviename without extension).movie

@echo off
for /r "E:\movies\" %%d in (.) do (
    pushd %%d
    echo now in %%d
    for %%f in (*.avi *.mkv *.mp4) do (
        md "%%~nf.movie"
    )
    popd 
) 

if you want it only by the name of Movie.(moviename without extension)

@echo off
for /r "E:\movies\" %%d in (.) do (
    pushd %%d
    echo now in %%d
    for %%f in (*.avi *.mkv *.mp4) do (
        md "%%~nf"
    )
    popd 
)

No comments:

Post a Comment