You are not logged in.
Well, situation is next. Have main folder called "Movies". In it folders with Movie names.
Structure is like this:
D:\Movies\Moviename\Moviename.avi
D:\Movies\Moviename\Moviename.srt
D:\Movies\Moviename\Moviename.jpg
D:\Movies\Moviename\CouldBeMoreFiles...
I want to rename all subtitle files (extension are .ass .srt .ssa .sub .txt) same as video file (extensions are .asf .avi .flv .mp4 .mkv .mp(e)g .wmv) in that folder so I can play subtitles on any device. Most of them/all requires same video/subtitle filename in order to be displayed.
Example:
D:\Movies\Green Zone [2010]\Green.Zone[2010]DvDrip-aXXo.avi
D:\Movies\Green Zone [2010]\Green Zone.srt
D:\Movies\Green Zone [2010]\green.zone-aXXo.nfoto be...
D:\Movies\Green Zone [2010]\Green.Zone[2010]DvDrip-aXXo.avi
D:\Movies\Green Zone [2010]\Green.Zone[2010]DvDrip-aXXo.srt
D:\Movies\Green Zone [2010]\green.zone-aXXo.nfo
I would like it if script could be used for other extensions, just rename/replace original and resulting ones. If I missed something to mention, ask.
Thanks!
TRUTH, FREEDOM, JUSTICE and FATHERLAND are the highest morale values which human is born, lives and dies for!
Offline
You mean there could be only one "video file (extensions are .asf .avi .flv .mp4 .mkv .mp(e)g .wmv)" in a folder
but any amount of "subtitle files (extension are .ass .srt .ssa .sub .txt)" ?
So the rule is:
Step 1
- enumerate all files from a folder
- find the "video file"
- take the name part of that "video file"
Step 2
- enumerate all files from a folder
- work on the "subtitle files"
- rename them with that video file base name, leaving original extension
?yes?
At the moment I can think of such workflow:
Step 1 - PS-Rule1
- enumerate all files from a folder
- find the "video file"
- take the name part of that "video file"
- store it somehow to a var or file or clipboard (http://www.den4b.com/forum/viewtopic.php?id=1754)
Step 2 - PS-Rule2
- get the content of the var or file or clipboard
- enumerate all files from a folder
- work on the "subtitle files"
- rename them with that video file base name, leaving original extension
(Or merged to single rule which you have to execute twice,.... I don' know at the moment if we could use a kind of "Initial procedure" to do this work for us?)
666 ^^
Read the *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)
Offline
You mean there could be only one "video file (extensions are .asf .avi .flv .mp4 .mkv .mp(e)g .wmv)" in a folder
but any amount of "subtitle files (extension are .ass .srt .ssa .sub .txt)" ?So the rule is:
Step 1
- enumerate all files from a folder
- find the "video file"
- take the name part of that "video file"
Step 2
- enumerate all files from a folder
- work on the "subtitle files"
- rename them with that video file base name, leaving original extension?yes?
Actually there could be 2 video files (for example movie have cd1 or cd2) so there are 2 subtitle files for both videos. In other cases 1 video file is with 1 subtitle file,...BUT it could be 2 or rarely 3 subtitle files as alternative in folder. And yes, that kind of procedure (step 1/step 2) just with this:
- if there are 2 or more same extensions fix conflicting new names
(Or merged to single rule which you have to execute twice,.... I don' know at the moment if we could use a kind of "Initial procedure" to do this work for us?)
So are you telling me that we cannot do anything about this?
Thanx for effort
TRUTH, FREEDOM, JUSTICE and FATHERLAND are the highest morale values which human is born, lives and dies for!
Offline
Does this do more or less what you wanted?
It takes the name of the first video it finds, probably that should be enough. But if not, we can make it give a warning or something.
var
BrotherFiles: TStringsArray;
BasePath: WideString;
I: Integer;
begin
if (Length(SubMatchesRegEx(FileName, '\.(ASS|SRT|SSA|SUB|TXT)$', False)) > 0) then
begin
BasePath := WideExtractFilePath(FilePath);
SetLength(BrotherFiles, 0);
WideScanDirForFiles(BasePath, BrotherFiles, False, False, False, '*');
For I:=0 to Length(BrotherFiles)-1 do
begin
if (Length(SubMatchesRegEx(BrotherFiles[i], '\.(ASF|AVI|FLV|MP4|MKV|MPE?G|WMV)$', False)) > 0) then
begin
FileName := WideExtractBaseName(BrotherFiles[i]) + WideExtractFileExt(FileName);
Break;
end;
end;
end;
end.
Last edited by SafetyCar (2013-05-14 07:45)
If this software has helped you, consider getting your pro version. :)
Offline
Does this do more or less what you wanted?
Just as you said more or less it's doing. There are titles that have more info than video files so I've switched extensions in PS and works
It takes the name of the first video it finds, probably that should be enough. But if not, we can make it give a warning or something.
Enough for many examples But... Try to handle these situations:
D:\Movies\King Kong [2005]\King Kong CD1 (2005)(1).srt
D:\Movies\King Kong [2005]\King Kong CD1 (2005).srt
D:\Movies\King Kong [2005]\King Kong CD2 (2005)(1).srt
D:\Movies\King Kong [2005]\King Kong CD2 (2005).srt
D:\Movies\King Kong [2005]\king-kong-2005-aXXo.nfo
D:\Movies\King Kong [2005]\King.Kong[2005]DvDrip.AC3[Eng]CD1-aXXo.avi
D:\Movies\King Kong [2005]\King.Kong[2005]DvDrip.AC3[Eng]CD2-aXXo.avi
D:\Movies\One Day 2011\1-3-3-8.com_l-oneday.xvid.cd2.avi
D:\Movies\One Day 2011\l-oneday.xvid.cd1.srt
D:\Movies\One Day 2011\l-oneday.xvid.cd2.srt
D:\Movies\One Day 2011\One Day 2011 BRRip XVID AbSurdiTy.avi
D:\Movies\The Manchurian Candidate\dmt-mancan-cd1.avi
D:\Movies\The Manchurian Candidate\dmt-mancan-cd1_SRPSKI_Duke2.srt
D:\Movies\The Manchurian Candidate\dmt-mancan-cd2.avi
D:\Movies\The Manchurian Candidate\dmt-mancan-cd2_SRPSKI_Duke2.srtbecomes
D:\Movies\King Kong [2005]\King.Kong[2005]DvDrip.AC3[Eng]CD1-aXXo.srt
D:\Movies\King Kong [2005]\King.Kong[2005]DvDrip.AC3[Eng]CD1-aXXo.srt
D:\Movies\King Kong [2005]\King.Kong[2005]DvDrip.AC3[Eng]CD1-aXXo.srt
D:\Movies\King Kong [2005]\King.Kong[2005]DvDrip.AC3[Eng]CD1-aXXo.srt
D:\Movies\King Kong [2005]\king-kong-2005-aXXo.nfo
D:\Movies\King Kong [2005]\King.Kong[2005]DvDrip.AC3[Eng]CD1-aXXo.avi
D:\Movies\King Kong [2005]\King.Kong[2005]DvDrip.AC3[Eng]CD2-aXXo.avi
D:\Movies\One Day 2011\1-3-3-8.com_l-oneday.xvid.cd2.avi
D:\Movies\One Day 2011\1-3-3-8.com_l-oneday.xvid.cd2.srt
D:\Movies\One Day 2011\1-3-3-8.com_l-oneday.xvid.cd2.srt (duplicate)
D:\Movies\One Day 2011\One Day 2011 BRRip XVID AbSurdiTy.avi
D:\Movies\The Manchurian Candidate\dmt-mancan-cd1.avi
D:\Movies\The Manchurian Candidate\dmt-mancan-cd1.srt
D:\Movies\The Manchurian Candidate\dmt-mancan-cd2.avi
D:\Movies\The Manchurian Candidate\dmt-mancan-cd1.srt (should be cd2!)
So if you can, try to modify script to handle occurrences with cd1 or cd2 to replace them properly.
Note: In 2nd folder 2nd video file don't have cd1 as it should so if you cannot made to correct itself never mind, it's only one occurrence.
Note2: If there are duplicates as in 1st folder "Fix conflicting new names" is used.
D:\Movies\Friends 5\Friends_S5_01.avi
D:\Movies\Friends 5\Friends_S5_01.srt
D:\Movies\Friends 5\Friends_S5_02.avi
D:\Movies\Friends 5\Friends_S5_02.srt
D:\Movies\Friends 5\Friends_S5_03.avi
D:\Movies\Friends 5\Friends_S5_03.srt
D:\Movies\Friends 5\Friends_S5_04.avi
D:\Movies\Friends 5\Friends_S5_04.srt
.
.
.becomes
D:\Movies\Friends 5\Friends_S5_01.avi
D:\Movies\Friends 5\Friends_S5_01.srt
D:\Movies\Friends 5\Friends_S5_02.avi
D:\Movies\Friends 5\Friends_S5_01.srt
D:\Movies\Friends 5\Friends_S5_03.avi
D:\Movies\Friends 5\Friends_S5_01.srt
D:\Movies\Friends 5\Friends_S5_04.avi
D:\Movies\Friends 5\Friends_S5_01.srt
.
.
.
If video and title are same ignore replacing.
I think that's it. Thanx again, you saved me a lots of renaming
TRUTH, FREEDOM, JUSTICE and FATHERLAND are the highest morale values which human is born, lives and dies for!
Offline
Enough for many examples
But... Try to handle these situations:
That is getting complex, I think is better to keep it simple...
Why not this?...
You add every file to renamer, and you sort the files first one video then it's subtitle, and so on.
And then with this script you put the name of the last video on the next file.
var
BasePath, LastPath, LastName: WideString;
begin
BasePath := WideExtractFilePath(FileName);
if (Length(SubMatchesRegEx(FileName, '\.(ASF|AVI|FLV|MP4|MKV|MPE?G|WMV)$', False)) > 0) then
begin
LastName := FileName;
LastPath := BasePath;
end
else
begin
if (BasePath <> LastPath) then
begin
LastPath := BasePath;
LastName := '';
end;
if (LastName <> '') then
begin
FileName := WideStripExtension(LastName) + WideExtractFileExt(FileName);
LastName := '';
end
else
begin
FileName := '';
end;
end;
end.
If you don't like the order, reorder it (Ctrl+Arrow) and preview again.
It's a little bit more work but it gives more awareness of what is changing, and I don't think that can be bad...
If this software has helped you, consider getting your pro version. :)
Offline
If you don't like the order, reorder it (Ctrl+Arrow) and preview again.
It's a little bit more work but it gives more awareness of what is changing, and I don't think that can be bad...
In my case it's lots of work It renames every file below video file no matter of extension (except video ext) and that is what we want to evade.
D:\Movies\King Kong [2005]\King.Kong[2005]DvDrip.AC3[Eng]CD1-aXXo.avi
D:\Movies\King Kong [2005]\King Kong CD1 (2005)(1).srt
D:\Movies\King Kong [2005]\King Kong CD1 (2005).srt
D:\Movies\King Kong [2005]\King.Kong[2005]DvDrip.AC3[Eng]CD2-aXXo.avi
D:\Movies\King Kong [2005]\King Kong CD2 (2005)(1).srt
D:\Movies\King Kong [2005]\King Kong CD2 (2005).srt
D:\Movies\King Kong [2005]\king-kong-2005-aXXo.nfobecomes
D:\Movies\King Kong [2005]\King.Kong[2005]DvDrip.AC3[Eng]CD1-aXXo.avi
D:\Movies\King Kong [2005]\King.Kong[2005]DvDrip.AC3[Eng]CD1-aXXo.srt
D:\Movies\King Kong [2005]\King Kong CD1 (2005).srt (ignored - should be as upper result)
D:\Movies\King Kong [2005]\King.Kong[2005]DvDrip.AC3[Eng]CD2-aXXo.avi
D:\Movies\King Kong [2005]\King.Kong[2005]DvDrip.AC3[Eng]CD2-aXXo.srt
D:\Movies\King Kong [2005]\King Kong CD2 (2005).srt (ignored - should be as upper result)
D:\Movies\King Kong [2005]\king-kong-2005-aXXo.nfo
Have to repeat/add files again
With modified:
D:\Movies\King Kong [2005]\King Kong CD1 (2005)(1).srt
D:\Movies\King Kong [2005]\King Kong CD1 (2005).srt
D:\Movies\King Kong [2005]\King Kong CD2 (2005)(1).srt
D:\Movies\King Kong [2005]\King Kong CD2 (2005).srt
D:\Movies\King Kong [2005]\king-kong-2005-aXXo.nfo
D:\Movies\King Kong [2005]\King.Kong[2005]DvDrip.AC3[Eng]CD1-aXXo.avi
D:\Movies\King Kong [2005]\King.Kong[2005]DvDrip.AC3[Eng]CD2-aXXo.avibecomes
D:\Movies\King Kong [2005]\King.Kong[2005]DvDrip.AC3[Eng]CD1-aXXo.srt
D:\Movies\King Kong [2005]\King.Kong[2005]DvDrip.AC3[Eng]CD1-aXXo.srt
D:\Movies\King Kong [2005]\King.Kong[2005]DvDrip.AC3[Eng]CD2-aXXo.srt
D:\Movies\King Kong [2005]\King.Kong[2005]DvDrip.AC3[Eng]CD2-aXXo.srt
D:\Movies\King Kong [2005]\king-kong-2005-aXXo.nfo
D:\Movies\King Kong [2005]\King.Kong[2005]DvDrip.AC3[Eng]CD1-aXXo.avi
D:\Movies\King Kong [2005]\King.Kong[2005]DvDrip.AC3[Eng]CD2-aXXo.avi
No matter of the order and thinking what and where to put. The simplest solution, don't you think?
First script is very good, I just suggested what criteria to add to make it even better to handle more things without changing the intended result, but if that cannot be modified than I'll use last PS.
TRUTH, FREEDOM, JUSTICE and FATHERLAND are the highest morale values which human is born, lives and dies for!
Offline
In my case it's lots of work
It renames every file below video file no matter of extension (except video ext) and that is what we want to evade.
What problem do you see in the last script? not avoiding non subtitle extensions? It can be added.
Have to repeat/add files again
I made the script clear the last name if it was already used, do you want to keep using it even if it creates duplicates?
No matter of the order and thinking what and where to put. The simplest solution, don't you think?
Not so simple to code...
First script is very good, I just suggested what criteria to add to make it even better to handle more things without changing the intended result, but if that cannot be modified than I'll use last PS.
Now, I tried to fix the previous one, and this is what came up: (I don't think I can get much better than this...)
var
BrotherFiles, VidFiles: TStringsArray;
BasePath, RExVid, RExSub: WideString;
I: Integer;
Found: Boolean;
begin
if (Length(SubMatchesRegEx(FileName, '\.(ASS|SRT|SSA|SUB|TXT)$', False)) > 0) then
begin
BasePath := WideExtractFilePath(FilePath);
SetLength(VidFiles, 0);
SetLength(BrotherFiles, 0);
WideScanDirForFiles(BasePath, BrotherFiles, False, False, False, '*');
For I:=0 to Length(BrotherFiles)-1 do
begin
if (Length(SubMatchesRegEx(BrotherFiles[i], '\.(ASF|AVI|FLV|MP4|MKV|MPE?G|WMV)$', False)) > 0) then
begin
SetLength(VidFiles, Length(VidFiles)+1);
VidFiles[Length(VidFiles)-1] := WideExtractBaseName(BrotherFiles[i]);
end;
end;
if (Length(VidFiles) > 0) then
begin
if (Length(VidFiles) = 1) then
begin
FileName := VidFiles[0] + WideExtractFileExt(FileName);
end
else
begin
RExSub := ReplaceRegEx(FileName, '^.*?((\b|_)(CD\d+)(\b|_)).*?$', '$3', False, True);
if (RExSub <> '') then
begin
Found := False;
For I:=0 to Length(VidFiles)-1 do begin
RExVid := ReplaceRegEx(VidFiles[i], '^.*?((\b|_)(CD\d+)(\b|_)).*?$', '$3', False, True);
if WideSameText(RExVid, RExSub) then
begin
Found := True;
FileName := VidFiles[i] + WideExtractFileExt(FileName);
Break
end;
end;
if (not Found) then
FileName := '';
end;
end;
end
else
begin
FileName := '';
end;
end;
end.
If this software has helped you, consider getting your pro version. :)
Offline
I made the script clear the last name if it was already used, do you want to keep using it even if it creates duplicates?
Not so simple to code...
You already done it
Now, I tried to fix the previous one, and this is what came up: (I don't think I can get much better than this...)
What I've asked, you made it. Works almost perfect for every occurred scenario! Thanx!
This was ignored only:
D:\Movies\Casshern\Casshern.jpg
D:\Movies\Casshern\Cassherncd1 Srp.srt
D:\Movies\Casshern\Cassherncd1.avi
D:\Movies\Casshern\Cassherncd2 Srp.srt
D:\Movies\Casshern\Cassherncd2.avi
...but never mind.
So, script finds video files (.asf .avi .flv .mp4 .mkv .mp(e)g .wmv) and renames corresponding subtitle files (.ass .srt .ssa .sub .txt) as video basenames. Also do:
- skips renaming of same basenames
- finds cd(digit) in filename and renames corresponding files containing cd(digit) [case insensitive]
- if there is surplus of subtitle file(s) in same folder it will be renamed as 1st one (must use "Fix conflicting new names")
Note: *.txt don't have to be subtitle file so be careful!
var
BrotherFiles, VidFiles: TStringsArray;
BasePath, RExVid, RExSub: WideString;
I: Integer;
Found: Boolean;
begin
if (Length(SubMatchesRegEx(FileName, '\.(ASS|SRT|SSA|SUB|TXT)$', False)) > 0) then
begin
BasePath := WideExtractFilePath(FilePath);
SetLength(VidFiles, 0);
SetLength(BrotherFiles, 0);
WideScanDirForFiles(BasePath, BrotherFiles, False, False, False, '*');
For I:=0 to Length(BrotherFiles)-1 do
begin
if (Length(SubMatchesRegEx(BrotherFiles[i], '\.(ASF|AVI|FLV|MP4|MKV|MPE?G|WMV)$', False)) > 0) then
begin
SetLength(VidFiles, Length(VidFiles)+1);
VidFiles[Length(VidFiles)-1] := WideExtractBaseName(BrotherFiles[i]);
end;
end;
if (Length(VidFiles) > 0) then
begin
if (Length(VidFiles) = 1) then
begin
FileName := VidFiles[0] + WideExtractFileExt(FileName);
end
else
begin
RExSub := ReplaceRegEx(FileName, '^.*?((\b|_)(CD\d+)(\b|_)).*?$', '$3', False, True);
if (RExSub <> '') then
begin
Found := False;
For I:=0 to Length(VidFiles)-1 do begin
RExVid := ReplaceRegEx(VidFiles[i], '^.*?((\b|_)(CD\d+)(\b|_)).*?$', '$3', False, True);
if WideSameText(RExVid, RExSub) then
begin
Found := True;
FileName := VidFiles[i] + WideExtractFileExt(FileName);
Break
end;
end;
if (not Found) then
FileName := '';
end;
end;
end
else
begin
FileName := '';
end;
end;
end.
TRUTH, FREEDOM, JUSTICE and FATHERLAND are the highest morale values which human is born, lives and dies for!
Offline