I've got a folder called "Movies" with several subfolders inside it, each having the title of a movie + a description as a name, let's say: "Blue Velvet (1986) - The Criterion Collection".

Inside each movie subfolder there's a number of files, typically a video file (with extensions such as .mkv, .mp4, .avi, .wmv etc.), a subtitle file (.srt extension) and sometimes a .jpg image. Those files have an alternative format of the movie title as a name, different than the name of the folder they are into e.g "Blue Velvet - David Lynch (1986)".

What I want to achieve is:

1. Create a text file inside each movie subfolder. The text file should have the exact same name with the subfolder in question.

then (I don't mind the order but I'm not sure the steps could be performed in the opposite direction)

2. Rename the movie subfolder, having it adopting the same name with the video (without the extension of course).

Or to put it in another way, since AFAIK there's not such thing as renaming folders when it comes to cmd and bat files but moving files between folders instead, I'd like to create a text file named after the movie subfolder then move it in a new folder named after the video filename, along with all the other files from the initial folder.


Movies/Blue Velvet (1986) - The Criterion Collection/
Blue Velvet - David Lynch (1986).mkv
Blue Velvet - David Lynch (1986).srt
Blue Velvet - David Lynch (1986).jpg


Movies/Blue Velvet - David Lynch (1986)/
Blue Velvet - David Lynch (1986).mkv
Blue Velvet - David Lynch (1986).srt
Blue Velvet - David Lynch (1986).jpg
Blue Velvet (1986) - The Criterion Collection.txt

Ideally I'd like the process to initiate by selecting folder(s) and fire up a bat. file either by a context menu action or "send to" the bat file, I know how to do both, I just want help with the command in the bat file. That way, using the previous example, I could process only the "Blue Velvet" and other selected movie subfolders and not necessarily everything in the "Movies" root folder in case some don't need sorting but if that's not possible, no problem. Special characters/symbols, numbers and spaces could be included in the folder and file names though. I've searched around and I couldn't find an answer to apply in my situation, I guess the trickiest parts are the subfolder "rename" and a way to perform the action only with selected movie subfolders and not every subfolder in the "Movies" root folder.

Any help would be greatly appreciated, thanks a lot!

1 Answer 1


Hm, I guess it would be something like this:

@echo off
Title Movie Folder Renamer
Rem Put the path to the movie folders here:
set MovieFolders=%CD%
set /p Pattern=Please inform the pattern: 
if /i "%Pattern%"=="*.*" set "Pattern=|Find /i ".""
pushd %MovieFolders%
Echo List of affected Folders:
dir /ad /b /p %Pattern%
echo What would you like to do? (C)ontinue ^| C(a)ncel ^| (N)ew Pattern
Choice /c "CAN"

if "%errorlevel%"=="2" Goto Exit
if "%errorlevel%"=="3" Goto Start
for /f "Delims=" %%a in ('dir /ad /b ^%Pattern%') do (
echo.> "%%a\%%~nxa.txt"
pushd "%%a"
for %%b in (*.mp4 *.mkv *.avi *.wmv *.asf *.mpg *.mpeg *.fla) do (
ren "%%a" "%%~nb"
if exist "%~pd0\NoSrt.txt" del "%~pd0\NoSrt.txt"
for /d %%c in (%MovieFolders%\*) do if not exist "%%c\*.srt" echo %%~nc >> %~dp0NoSrt.txt


enter image description here


enter image description here

  • It's actually "A Star is Born" not "A Star is Bron" LOL Nov 2, 2019 at 19:17
  • Thanks a lot for you reply. It seems to mostly work, however, if there a period in the folder name (and this is often the case), it's ignored in the text file filename as much as every character following it. For an "Aliens.1986" folder, I get an "Aliens" text file, period and 1986 are getting truncated.
    – Slade
    Nov 3, 2019 at 11:42
  • I made a small change on the code, can you check again... Nov 3, 2019 at 13:59
  • After some testing this one seems to work great! Thanks a lot! I wondered if it was possible to set MovieFolders="%cd%" in order to be able to run the bat file from any folder rather than a fixed one and it seemed to worked too. I've also tried to run it from the cmd window (after removing the extra % symbols) and that also seemed to work. Do you think there's a chance for things to go wrong i.e maybe overwrite/lose data if I follow those routes? Finally, is there a way to have the command target selected (control+click) movie subfolders rather the entire folder?
    – Slade
    Nov 3, 2019 at 19:40
  • I guess you can use the MovieFolders=%CD% as long as you run the script on the root of the movie folders. I don't think there is a big chance of losing data since all it does is rename folders and create a txt file but it is always good to have a backup somewhere. There is not really CTRL+Cick option in batch like in Windows explorer where you can randomly select folders by clicking. What I could implement is that the program asks for a pattern ex: What pattern would you like to use?[the user enters:*Movie* and only folders that have "Movie" in the name would be affected] Nov 3, 2019 at 21:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.