You are not logged in.
But... with the old script...
FOLDER S00(2)
would be:
FOLDER S 00(2)
isn't it?
If this software has helped you, consider getting your pro version. :)
Offline
No, with the old script the 00 is incremented, so I have (without file inside):
FOLDER S02(0)
Here is the script I'm using.
var
NameData, Files: TStringsArray;
Total, Deleted, Current, Previous: Integer;
begin
NameData := SubMatchesRegEx(FileName, '^(.*?)(\d+)\((\d+)\)$', False);
If (length(NameData)<>3) then Exit;
SetLength(Files, 0);
WideScanDirForFiles(FilePath, Files, False, False, False, '*.mkv');
WideScanDirForFiles(FilePath, Files, False, False, False, '*.avi');
WideScanDirForFiles(FilePath, Files, False, False, False, '*.wmv');
Current := Length(Files);
Deleted := StrToInt(NameData[1]);
Previous := StrToInt(NameData[2]);
If (Current<Previous) then
begin
Total := Deleted + Previous;
NameData[1] := IntToStr(Total - Current);
end;
If (length(NameData[1])=1) then NameData[1] := '0' + NameData[1];
NameData[2] := IntToStr(Current);
FileName := NameData[0] + NameData[1] + '(' + NameData[2] + ')';
end.
_________________
Do, or do not. There is no 'try.'" -- Jedi Master Yoda
Offline
Sorry, I'm a mess right now.
I'm still wondering about "increment only when I have "-vu"", I'm not seeing it in the examples you gave after.
Anyway, take a look at this one:
var
NameData, Files: TStringsArray;
Total, Deleted, Current, Previous: Integer;
begin
NameData := SubMatchesRegEx(FileName, '^(.*?)(\d+)\((\d+)\)$', False);
If (length(NameData)<>3) then Exit;
if (WideTextPos('-vu ', NameData[0])=0) then
begin
NameData[0] := NameData[0] + NameData[1] + '-vu ';
NameData[1] := '0';
end;
SetLength(Files, 0);
WideScanDirForFiles(FilePath, Files, False, False, False, '*.mkv');
WideScanDirForFiles(FilePath, Files, False, False, False, '*.avi');
WideScanDirForFiles(FilePath, Files, False, False, False, '*.wmv');
Current := Length(Files);
Deleted := StrToInt(NameData[1]);
Previous := StrToInt(NameData[2]);
If (Current<Previous) then
begin
Total := Deleted + Previous;
NameData[1] := IntToStr(Total - Current);
end;
If (length(NameData[1])=1) then NameData[1] := '0' + NameData[1];
NameData[2] := IntToStr(Current);
FileName := NameData[0] + NameData[1] + '(' + NameData[2] + ')';
end.
If this software has helped you, consider getting your pro version. :)
Offline
Sorry... I didn't sleep very well today
Maybe this one...
var
NameData, Files: TStringsArray;
Total, Deleted, Current, Previous: Integer;
begin
NameData := SubMatchesRegEx(FileName, '^(.*?)(\d+)\((\d+)\)$', False);
If (length(NameData)<>3) then Exit;
WideScanDirForFiles(FilePath, Files, False, False, False, '*.mkv');
WideScanDirForFiles(FilePath, Files, False, False, False, '*.avi');
WideScanDirForFiles(FilePath, Files, False, False, False, '*.wmv');
SetLength(Files, 0);
Current := Length(Files);
if (WideTextPos('-vu ', NameData[0])=0) then
begin
NameData[0] := NameData[0] + NameData[1] + '-vu ';
NameData[1] := '00';
end
else
begin
Deleted := StrToInt(NameData[1]);
Previous := StrToInt(NameData[2]);
If (Current<Previous) then
begin
Total := Deleted + Previous;
NameData[1] := IntToStr(Total - Current);
end;
If (length(NameData[1])=1) then NameData[1] := '0' + NameData[1];
end;
NameData[2] := IntToStr(Current);
FileName := NameData[0] + NameData[1] + '(' + NameData[2] + ')';
end.
If this software has helped you, consider getting your pro version. :)
Offline
This is it.
Even better than my idea because you've done it in one test..
But it's my mistake, I thought that the regex will always give
NameData := SubMatchesRegEx(FileName, '^(.*?)(\d+)\((\d+)\)$', False);
NameData[0] -> FOLDER S
This is why I am a little lost and I can't "understand" the WideTextPos with NameData[0]
Can you explain the first regex and the result, please!?
But, anyway, thanks for the help and the upgrade....
_________________
Do, or do not. There is no 'try.'" -- Jedi Master Yoda
Offline
You post when I was writing...
But the first work as well...
_________________
Do, or do not. There is no 'try.'" -- Jedi Master Yoda
Offline
The first is working and not the second:
with first
ACA S01(2) ACA S01-vu 02(0)
ACA S02-vu 01(2) ACA S02-vu 03(0)
ACA S03-vu 05(1) ACA S03-vu 05(2)
aca S04(0) aca S04-vu 00(0)
with second
ACA S01(2) ACA S01-vu 00(0)
ACA S02-vu 01(2) ACA S02-vu 03(0)
ACA S03-vu 05(1) ACA S03-vu 06(0)
aca S04(0) aca S04-vu 00(0)
Last edited by ozzii (2011-10-05 16:33)
_________________
Do, or do not. There is no 'try.'" -- Jedi Master Yoda
Offline
The first is working and not the second
Well... take the first then
I thought that the regex will always give
NameData := SubMatchesRegEx(FileName, '^(.*?)(\d+)\((\d+)\)$', False);
NameData[0] -> FOLDER SThis is why I am a little lost and I can't "understand" the WideTextPos with NameData[0]
Can you explain the first regex and the result, please!?
In fact, it does.
The RegEx searches for
^ > From the start
(.*?) > NameData[0] = Anything until...
(\d+) > NameData[1] = Digits
\( > Open parenthesis
(\d+) > NameData[2] = More digits
\) > Close parenthesis
$ > End of text
The problem was that we caught the first digits without having to take them, so I brought them back to where they should be with NameData[0] := NameData[0] + NameData[1];
But, anyway, thanks for the help and the upgrade....
Happy to help.
If this software has helped you, consider getting your pro version. :)
Offline