Batch File To Rename File Inside Of A Folder To The Folder Name, Plus More...

Started by Thaum2u, May 29, 2022, 02:03:03 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Thaum2u

I have a folder full of other folders, each containing a different movie file and sometimes subtitles.

The person I got the hard drive from named all of the movies in an ugly (to me) way, and they are not all named following the same convention. Meaning some have periods between each word while some don't, and some have stuff at the end of the filename that others do not. So there would be no easy way to automate renaming them that I can think of.

So what I started to do was to rename the folders, since the folder names are usually closer to my desired naming convention than the file inside the folder, making them quicker to rename. 

Then I highlight and copy the folder name that I just renamed, and rename the movie file inside by pasting the folder name as the file name. Then I cut the file and paste it to the folder I want all the movies in.

To be clear, I want all the movies to end up in the parent folder that contained the folders of each movie.

The way I want the movies named is as follows:

  --> Movie Name [year].ext

     A Street Cat Named Bob [2016].mp4
     A Street Cat Named Bob [2016].srt
     A.I. - Artificial Intelligence [2001].mp4
     Airplane! (Criterion Collection) [1980].mkv
    
The file extensions I would want to rename would be any file with the following extensions:

          .mp4
     .mkv
     .srt
     .idx
     .sub
     .jpg

I'd like a batch file that will allow me to drag and drop the folder that contains all the other movie folders ( for example: c:/movies/ ), and have it go into each folder to rename the movie files inside of their respective folders, and then move each renamed files back to the parent folder that the folder was in:

BEFORE:
c:/movies/A Street Cat Named Bob [2016]/A.Street.Cat.Named.Bob.2016.720p.h264.mp4
c:/movies/A Street Cat Named Bob [2016]/A.Street.Cat.Named.Bob.2016.720p.h264.srt
c:/movies/A.I. - Artificial Intelligence [2001]/A.I.2001.720p.h265.AAC.mp4
c:/movies/Airplane! (Criterion Collection) [1980]/Airplane (Criterion Collection) 1980 (DTS) (1080p).mkv

AFTER:
c:/movies/A Street Cat Named Bob [2016].mp4
c:/movies/A Street Cat Named Bob [2016].srt
c:/movies/A.I. - Artificial Intelligence [2001].mp4
c:/movies/Airplane! (Criterion Collection) [1980].mkv

I've seen examples of similar things on here, but I have a hard time understanding and following most of the loop stuff enough to attempt this on my own.

I would prefer to do this with a batch file instead of a program like Bulk Rename Utility, because I might want to modify and add functionality to it later, and hopefully learn from it as well.

Thanks for any help.


Hackoo

Hi  ;)
Can you post me the contents of this file ListAll.txt after generation by this batch file :
@echo off
CD /D %~dp0
DIR /B /S>ListAll.txt
Start "" /MAX ListAll.txt