You are not logged in.
To do something only one time you can use
var
Initialized: Boolean;
begin
if not Initialized then
begin
Prefix := InputBox('Prefix', 'Please type in the Prefix', 'Vacation_');
Initialized := True;
end;
-other code
end.
or use the latest beta (27.01) from the download page
to utilize
begin
if(GetCurrentFileIndex=1)then
begin
-other code
end;
end.
See http://www.den4b.com/forum/viewtopic.php?pid=7377#p7377
- - -
To store a value for reuse see
http://www.den4b.com/forum/viewtopic.php?pid=7385#p7385
http://www.den4b.com/wiki/ReNamer:Scrip … e_variable
But since i often has to clear variables at then end of an script, to have it fresh for the next file,
i would try it first, if not the value is remembered anyway during the life of the run.
.
-
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
Thanks a LOT again!
I now have:
var
Prefix, Suffix, Digits, Candidate: WideString;
I, Pad: Integer; Initialized: Boolean;
begin
if not Initialized then
begin
Prefix := InputBox('Prefix', 'Please type in the Prefix', 'Vacation_');
Initialized := True;
end;
//Prefix := 'Photo'; //file name part before the digits, like 'Vacation_'
Suffix := ''; //file name part after the digits, like '_Paris2013'
Pad := 3; // amount of digits in serial number, like '001' are three (3)
Prefix := WideExtractFileDir(FilePath) + '\' + Prefix;
Suffix := Suffix + WideExtractFileExt(FilePath);
repeat
I := I + 1;
Digits := IntToStr(I);
while (length(Digits) < Pad) do Digits := '0' + Digits;
Candidate := Prefix + Digits + Suffix;
until (not WideFileExists(Candidate));
FileName := Candidate;
// FileName := WideReplaceText(FileName, WideExtractFileDir(FilePath)+'\', '');
end.
But its giving me invalid file names.
And i cant make much sense of the "if(GetCurrentFileIndex=1)then" - it seems i get the same errors with it.
see:
var
Prefix, Suffix, Digits, Candidate: WideString;
I, Pad: Integer;
begin
begin
if(GetCurrentFileIndex=1)then
Prefix := InputBox('Prefix', 'Please type in the Prefix', 'Vacation_');
end;
//Prefix := 'Photo'; //file name part before the digits, like 'Vacation_'
Suffix := ''; //file name part after the digits, like '_Paris2013'
Pad := 3; // amount of digits in serial number, like '001' are three (3)
Prefix := WideExtractFileDir(FilePath) + '\' + Prefix;
Suffix := Suffix + WideExtractFileExt(FilePath);
repeat
I := I + 1;
Digits := IntToStr(I);
while (length(Digits) < Pad) do Digits := '0' + Digits;
Candidate := Prefix + Digits + Suffix;
until (not WideFileExists(Candidate));
FileName := Candidate;
// FileName := WideReplaceText(FileName, WideExtractFileDir(FilePath)+'\', '');
end.
Last edited by Jack28 (2013-01-29 21:51)
Offline
Thanks a LOT again!
But its giving me invalid file names.
Over to Safety since i have not study his code yet.
But would help if you tell more details: how do the invalid names look about? My crystal bowl is broken.
And i cant make much sense of the "if(GetCurrentFileIndex=1)then" - it seems i get the same errors with it.
see:
var Prefix, Suffix, Digits, Candidate: WideString; I, Pad: Integer; begin begin if(GetCurrentFileIndex=1)then Prefix := InputBox('Prefix', 'Please type in the Prefix', 'Vacation_'); end; end.
Again: more details! Which errors?
And please use the code right. Take an look at my example again. You have mixed up the lines
begin
if x=Y then
begin
...
end;
...
...
end.
.
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 are not allowed to post links"
i got this result (the New Names):
C:\Gallery001\Photo020.jpg
C:\Gallery001\C:\Gallery001\Photo021.jpg
C:\Gallery001\C:\Gallery001\C:\Gallery001\Photo022.jpg
with this code:
var
Prefix, Suffix, Digits, Candidate: WideString;
I, Pad: Integer;
begin
if(GetCurrentFileIndex=1)then
begin
Prefix := InputBox('Prefix', 'Please type in the Prefix', 'Vacation_');
end;
//Prefix := 'Photo'; //file name part before the digits, like 'Vacation_'
Suffix := ''; //file name part after the digits, like '_Paris2013'
Pad := 3; // amount of digits in serial number, like '001' are three (3)
Prefix := WideExtractFileDir(FilePath) + '\' + Prefix;
Suffix := Suffix + WideExtractFileExt(FilePath);
repeat
I := I + 1;
Digits := IntToStr(I);
while (length(Digits) < Pad) do Digits := '0' + Digits;
Candidate := Prefix + Digits + Suffix;
until (not WideFileExists(Candidate));
FileName := Candidate;
// FileName := WideReplaceText(FileName, WideExtractFileDir(FilePath)+'\', '');
end.
Offline
I got it... had to put this:
Prefix := WideExtractFileDir(FilePath) + '\' + Prefix;
to here:
if not Initialized then
begin
Prefix := InputBox('Prefix', 'Please type in the Prefix', 'Vacation_');
Prefix := WideExtractFileDir(FilePath) + '\' + Prefix;
Initialized := True;
end;
Offline
You need to push some more code into the initialization, else you'll always add the path again and again to the suffix.
It could also be rewritten to split more independent vars like Stefan had in the original, but I'll just do it this way:
var
Prefix, Suffix, Digits, Candidate: WideString;
I, Pad: Integer;
Initialized: Boolean;
begin
if not Initialized then
begin
//Prefix := 'Photo'; //file name part before the digits, like 'Vacation_'
Prefix := InputBox('Prefix', 'Please type in the Prefix', 'Vacation_');
Suffix := ''; //file name part after the digits, like '_Paris2013'
Pad := 3; // amount of digits in serial number, like '001' are three (3)
Prefix := WideExtractFileDir(FilePath) + '\' + Prefix;
Suffix := Suffix + WideExtractFileExt(FilePath);
Initialized := True;
end;
repeat
I := I + 1;
Digits := IntToStr(I);
while (length(Digits) < Pad) do Digits := '0' + Digits;
Candidate := Prefix + Digits + Suffix;
until (not WideFileExists(Candidate));
FileName := Candidate;
// FileName := WideReplaceText(FileName, WideExtractFileDir(FilePath)+'\', '');
end.
If this software has helped you, consider getting your pro version. :)
Offline
Thank you both, a LOT!
Offline