You are not logged in.
You remember the script that I sent you?
Try changing the line:
while Exists(Path + NewName) do
into
while Exists(Path + NewName) or WideFileExists(Path + NewName + Ext) do
This should force the code to add counter if the destination file already exists.
Didn't try it my self, so tell me how it goes, ok?
Offline
Didn't try it my self, so tell me how it goes, ok?
thank you but it doesn't work.
it adds "(2)" in the back even no the same filename (ignore extension) in that folder. I also delete the folder and it still changes to (2) by itself.
thank you!
Last edited by bobyang (2007-05-12 18:43)
Offline
I looked at the list of rules from your previous examples, and I think this might happen because your script rule is not the last in a sequence. At the moment where the script is executed, the new name might not change yet, causing the file to clash with itself on pascalscript rule, thus, adding the (2), (3), etc. Anyway, try placing the script as the last rule...
Offline
I looked at the list of rules from your previous examples, and I think this might happen because your script rule is not the last in a sequence. At the moment where the script is executed, the new name might not change yet, causing the file to clash with itself on pascalscript rule, thus, adding the (2), (3), etc. Anyway, try placing the script as the last rule...
thank you! but it doens't work. I move it to the last statement and I still got the same thing.
However, I cannot really use it as the last statement because I have to run these before it: 1.don't do anything for & files and 2. move to the correct folder
thank you!!
Offline
96 rules... never seen anybody to use that many
Anyway, what happens - is exactly what I said. Before running last 2 rule, your new names are:
user1-test.txt
user1-test2.txt2
The script works with these names, and that is why they get serialized (their respective paths are already taken by then-selves).
Put the script as 96'th rule - as the last rule, and it should work. Run everything BEFORE that script.
Offline
96 rules... never seen anybody to use that many
Anyway, what happens - is exactly what I said. Before running last 2 rule, your new names are:
user1-test.txt
user1-test2.txt2The script works with these names, and that is why they get serialized (their respective paths are already taken by then-selves).
Put the script as 96'th rule - as the last rule, and it should work. Run everything BEFORE that script.
thank you! I know the problem now.. because I after eidting the script I click on "close" instead of "add" which will not save it . and I capture the wrong screen in the last messeage.
However, it doens't fix the problem. i moved the script to the rule 96 and I get the same result.
Moreover, if I move it to the last statement, I cannot put them into different folders (rule 94 doens't take action)
thank you!
Offline
I think you need to send me over your preset file, with all the rules...
Offline
I think you need to send me over your preset file, with all the rules...
thank you! I have updated to here
http://www.sendspace.com/file/94nwou
Offline
Found a problem, and fixed it. Use the code below as your LAST (96-th) rule.
I replaced the WideExtractBaseName() with WideStripExtension(), because the first one actually removed the previously added folder name (by one of your rules). This new function is only available in the latest development version, which you can get from here: ReNamerBeta.zip
I tried it with sample files that you sent me, and it worked perfectly!
P.S. To optimize and shorten your 96 rules, you should change the Replace rules (which simply remove things) to Remove rule, and you could also group them together into one rule, because both Replace and Remove rule have multi-part delimiter which lets you do several operations in one rule.
var
Files: TStringsArray;
procedure Add(const S: WideString);
begin
SetLength(Files, Length(Files)+1);
Files[Length(Files)-1] := S;
end;
function Exists(const S: WideString): Boolean;
var I: Integer;
begin
Result := False;
for I:=0 to Length(Files)-1 do
if WideSameText(Files[i], S) then
begin Result := True; Break; end;
end;
var
NewName, Path, Name, Ext: WideString;
Counter: Integer;
begin
Counter := 2;
Ext := WideExtractFileExt(FileName);
Name := WideStripExtension(FileName);
Path := WideExtractFilePath(FilePath);
NewName := Name;
while Exists(Path + NewName) or WideFileExists(Path + NewName + Ext) do
begin
NewName := Name +'(' + IntToStr(Counter)+')';
Counter := Counter + 1;
end;
Add(Path + NewName);
FileName := NewName + Ext;
end.
Offline
Found a problem, and fixed it. Use the code below as your LAST (96-th) rule.
I replaced the WideExtractBaseName() with WideStripExtension(), because the first one actually removed the previously added folder name (by one of your rules). This new function is only available in the latest development version, which you can get from here: ReNamerBeta.zip
I tried it with sample files that you sent me, and it worked perfectly!
P.S. To optimize and shorten your 96 rules, you should change the Replace rules (which simply remove things) to Remove rule, and you could also group them together into one rule, because both Replace and Remove rule have multi-part delimiter which lets you do several operations in one rule.
thank you!
and you can group them? nice! that's waht i want to do before about grouping!
yes, I should use remove instead of replace. the only reason I used it because I was thinking to setup one rule for all people to use and they may have special request of they watn to changing instead of removing. However, I only see two people asking me how to replace so I guess I can change it to remove instead to speed up.
Offline