You are not logged in.
I just wonder if it is possible. thanks. the only thing I found is http://www.den4b.com/forum/viewtopic.php?id=155 but it is not quiet what I need. thanks!
here is something I want:
person-docname.txt -> person-docname.txt
person-docname.doc -> person-docname(2).doc
....
what I did is
1. remove extension
2. use pascalscript to add (2)
3.... I dont' know how to add back the original extension...
thank you!
could you also teach me how to write regexp correctly for unicode. thank you! I use it but it doens't return the way I but it returns correctly for non-unicode words.
thank you!!!!!!!!!!
Last edited by bobyang (2007-05-08 03:32)
Offline
PascalScript has a preloaded script called "Serialize Duplicates", which does almost what you wanted, except it serializes them based on the full name match (including extension). So I modified it a bit, and below is the code that will work as you wanted:
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, Ext: WideString;
Counter: Integer;
begin
Counter := 2;
Ext := WideExtractFileExt(FileName);
NewName := WideExtractBaseName(FileName);
while Exists(NewName) do
begin
NewName :=
WideExtractBaseName(FileName) +
' (' + IntToStr(Counter)+')';
Counter := Counter + 1;
end;
Add(NewName);
FileName := NewName + Ext;
end.
NOTE: This code only checks the new name, it doesn't check the PATH. This means that 2 files with the same base name but in different folders will also get serialized! If this behavior doesn't suite you, say so, and i'll modify it again.
Offline
Here is the solution for your Unicode problem:
Expression: (.+?)-(.*)
Replace: $1\\$0
Offline
Here is the solution for your Unicode problem:
Expression: (.+?)-(.*)
Replace: $1\\$0
thank you!!! this works wonderfully! I thought "W" was for unicode. I try to learn regexp but keep on forget all those key words
Offline
NOTE: This code only checks the new name, it doesn't check the PATH. This means that 2 files with the same base name but in different folders will also get serialized! If this behavior doesn't suite you, say so, and i'll modify it again.
This code is great! however, I hope filename will not change if they are in the different folders. could you help me with that. thank you! and sorry take your time for that.
thank you! thank you!
Offline
Here is the code that will handle files from different directories (test it first):
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 := WideExtractBaseName(FileName);
Path := WideExtractFilePath(FilePath);
NewName := Name;
while Exists(Path + NewName) do
begin
NewName := Name +' (' + IntToStr(Counter)+')';
Counter := Counter + 1;
end;
Add(Path + NewName);
FileName := NewName + Ext;
end.
Offline
I thought "W" was for unicode. I try to learn regexp but keep on forget all those key words
I thought so as well, but as we both see - we were mistaken
Perhaps, "\w" stand for only english alpha-numeric...
Offline
woderful! every thing works very good! and you are fast! I have added them into the script foder for the future usage!
thank you! thank you! thank you!
two more questions.
1. is it possible to detect the files are there already and rename it by adding (2), (3)....?
2. I like to check if the rename has "&" in the filename. if so, don't move it to a new folder. thank you!
hope something like below.
solved:
this is waht I do
1. add reg exgeX
(.+?)&(.+?)-(.*) to $1&$2___$3
2. add
(.*?)-(.*) to $1\\$0
3. add "replace" from "___" to "-"
Last edited by bobyang (2007-05-10 00:24)
Offline
Glad that you've solved one of your problems!
Other problem: Yes, possible! In fact, ReNamer already detects it, and notifies you of that.
1) Add all of your files/folder to renamer;
2) Set the rules and press Preview (and possibly Rename);
3) Files/folders that are duplicated or already exist will be marked with a warning/failed sign;
4) Right-click on the table "Clearing" -> "Clear Valid" or "Clear Successful" (if you Renamed)
5) Now you are left only with the duplicated files/folders;
6) Use SERIALIZE rule to add number sequences in any format you want!!
That will work 100% sure without any scripts!
Offline
Glad that you've solved one of your problems!
Other problem: Yes, possible! In fact, ReNamer already detects it, and notifies you of that.
1) Add all of your files/folder to renamer;
2) Set the rules and press Preview (and possibly Rename);
3) Files/folders that are duplicated or already exist will be marked with a warning/failed sign;
4) Right-click on the table "Clearing" -> "Clear Valid" or "Clear Successful" (if you Renamed)
5) Now you are left only with the duplicated files/folders;
6) Use SERIALIZE rule to add number sequences in any format you want!!That will work 100% sure without any scripts!
thank you! however, is there any script I can use for this? I tried to publish it after it works and have all other people use it.
a group of peopel and I have hard time to clean up the filename and all those process for a karaoke system which required us to do all those. I am thinking if i can create something by using your software with pre-set configiration, then I can give it to all people by just click on "preview" and "rename" to have everything done and make those people easy.
thank you!
Offline