As far as I understood...
YOU HAVE:
base directory\
--sub-directory-1\
--sub-directory-1\subtitles_file.SRT
--sub-directory-1\
movie_file1.MP4
--sub-directory-2\
--sub-directory-2\subtitles_file.SRT
--sub-directory-2\
movie_file2.MP4
--sub-directory-3\
--sub-directory-3\subtitles_file.SRT
--sub-directory-3\
movie_file3.MP4
YOU WANT:
- for each "sub-directory"
--- get base name of MP4
--- set base name of SRT to base name of MP4
TO GET:
base directory\
--sub-directory-1\
--sub-directory-1\
movie_file1.SRT
--sub-directory-1\
movie_file1.MP4
--sub-directory-2\
--sub-directory-2\movie_file2.SRT
--sub-directory-2\movie_file2.MP4
--sub-directory-3\
--sub-directory-3\movie_file3.SRT
--sub-directory-3\movie_file3.MP4
- - -
Me think for AHK you must use loops.
Here is some dummy code for an start to get the idea:
Code: Select all
; // ## DUMMY code only !!! , read the help
;//From base-directory, loop sub-folders
Loop, FilePattern [, IncludeFolders?, Recurse?]
{
;// on each sub-folder "A_LoopFileName", loop *MP4-files
Loop, FilePattern *.MP4 [, IncludeFolders?, Recurse?]
{
myMP4 = "A_LoopFileName"
break
}
;// on each sub-folder "A_LoopFileName", loop *SRT-files
Loop, FilePattern *.SRT [, IncludeFolders?, Recurse?]
{
mySRT = "A_LoopFileName"
break
}
;//Get new file name (use MP4-name and just replace the extension):
StringReplace, OutputVar myNewFileName, InputVar myMP4, SearchText MP4 , ReplaceText SRT
;//"Rename":
FileMove, SourcePattern mySRT, DestPattern myNewFileName
}
Of course there will be much more elegant code as that above...
In last times I wasn't much into AHK, so we will have to wait for an better script(er)

.
- - -
Here is an PowerShell script
USAGE:
- make an BACKUP first!
- open powershell console in your "base directory"
- execute this script line below:
Get-ChildItem -Directory|ForEach{$MP4=Get-ChildItem $_\*.MP4;$SRT=Get-ChildItem $_\*.SRT;Rename-Item $srt ($MP4.BaseName + ".SRT")}
THIS script works only if there is only one MP4 and only one SRT in each folder.
Else we would have to use something like "$MP4=Get-ChildItem $_\*.MP4|Select -First 1;"
And you will need to have a recent PoSh-version which supports "-Directory" for "Get-ChildItem",
else we would need to utilize "$PSisContainer", all that just in case if you will have also files in your "base directory".
Again the code but more formatted:
Get-ChildItem -Directory|
ForEach{
$MP4=Get-ChildItem $_\*.MP4;
$SRT=Get-ChildItem $_\*.SRT;
Rename-Item $srt ($MP4.BaseName + ".SRT")
}