Click here to Skip to main content
15,889,403 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a movie collection setup on my nas and am trying to rename all of my subtitle files to the same name as the movie located in the same directory. For example:

D:\Movies\2 Guns (2013) (Bluray)\
-2 Guns (2013).mkv
-English.srt

I would like for the english.srt file to be renamed to:

2 Guns (2013).srt


Long story short, I can't use any type of media manager to accomplish this. I would love for it to be a batch file, but am willing to use powershell or even a 3rd party program as long as it isn't a media manager of some sort. I need the name to be generated based off the largest file located in the same directory, not the folder name as some of these do not match the filenames. Also, the .srt files will not always be named english.srt

Thanks in advance for your time/info!

What I have tried:

I honestly am still struggling with learning powershell and batch commands, but was able to come up with the following:

@echo off
setlocal enabledelayedexpansion
for /F "delims=" %%A in ('dir /b *.mp4 *.avi *.mkv') do (
set basename="%%~nA"
ren *.srt !basename!.eng.srt
)



This works beautifully, but I can't figure out how to get it to run recursively. I'd like to run this from D:\Movies rather than folder by folder. I tried dir /b /s but that doesn't seem to make a difference.
Posted
Updated 28-Sep-16 14:49pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900