You are not logged in.
Pages: 1
Hi Denis,
please tell if there is a quick and easy way for Renamer to delete duplicate filenames, or rather files sharing the same name in the application's "New Name" list (after applying certain rules, but before renaming process) from my local disk. No need to serialize or rename duplicates in any other way, nor removing from the list itself, simply leave the first file with a certain name and delete the rest with identical directly from source folder(-s).
Sorry for my poor English and thanks in advance.
Offline
Hi and welcome!
You can use this modified script from Denis as last 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
NewFileName: WideString;
Counter: Integer;
begin
Counter := 2;
NewFileName := FileName;
while Exists(NewFileName) do
begin
NewFileName := 'dup_'+ IntToStr(Counter) + '_'
+ WideExtractBaseName(FileName) +
+ WideExtractFileExt(FileName);
Counter := Counter + 1;
end;
FileName := NewFileName;
Add(FileName);
end.
The script is changed to add serialisation of duplicate file names at the beginning of the names instead of the end as usual.
Deutsch.txt >> dup_2_new name.txt
French.txt >> dup_3_new name.txt
Czech.txt >> new name.txt
That way it is easy to sort and select that duplicates.
After an preview
- sort the NewName column,
- select the duplicated names
- and chose context menu > Shell > Delete Files
- - -
Perhaps we could also add a delete command to the script,
but such automatism are slightly dangerous by deleting unwanted files.
function WideDeleteFile(const FileName: WideString): Boolean;
Delete physical file from the disk. Returns TRUE on success, otherwise FALSE.
#####################################
On my way, I have tried to rename duplicate names by adding a trailing number
and '.dup' as extension, and then utilize 'Mark by Mask [ *.dup]',
but that command work only on the Name column,
... same with the Extension column which shows the Ext from the Name column.
NewFileName := WideExtractBaseName(FileName)
+ '_' + IntToStr(Counter) + '.dup';
Counter := Counter + 1;
Deutsch.txt >> new name_2.dup
French.txt >> new name_3.dup
Czech.txt >> new name.txt
But, this would work after the first renaming at an second run.
Or, if all files have the same ext, we had could select that ext, and then invert the selection to select all *.dup.
.
Last edited by Stefan (2013-10-10 20:19)
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
Another way and possibly a simpler one....
Go ahead and press Rename and let duplicated files fail to be renamed.
Then, right-click on the files table and select "Clear" -> "Clear Renamed".
This will leave you only with files that have failed to get renamed, i.e. duplicated files in your case.
Now select all of the remaining files and choose "Shell" -> "Delete Files to Recycle Bin".
Offline
Hi for everyone.
I have a simple question:
Is it possiple to add the dup_1_ prefix for the first (main) file?
I mean:
dup_1_filename
dup_2_filename
dup_3_filename
instead of
filename
dup_2_filename
dup_3_filename
Thanx.
Last edited by stransistors (2017-08-16 21:20)
Offline
Hi and welcome.
Is it possiple to add the dup_1_ prefix for the first (main) file?
Me think that is not easy done.
See, we work on current, and then on "future" files, not on "past" files.
Only on the second file we can see that there will be a duplicate name, but we do not process that first file anymore.
I can imagine work around with "WideRenameFile(OldName,NewName)", but I am not sure if that will work (*).
But I may be totally wrong on this. Let's hear what the author will say.
Maybe better the other way around on a second run with another script:
- process each file
--- current file: NameX
----- check if dub_2_NameX exists
---------if yes, rename NameX to dub_1_NameX
- - -
* Test idea
while Exists(NewFileName) do
begin
NameOne:=FileName
..
..
end;
FileName := NewFileName;
Add(FileName);
if(NameOne<>'') Then
begin
WideRenameFile(WideExtractFilePath(FilePath)+ NameOne, WideExtractFilePath(FilePath) + 'dup_1_' + NameOne);
NameOne:='';
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
Thanks for answer @Stefan.
I will try and share the consequence.
Offline
Hello
I have found this sotware and the only thing that is prevent to use it is overwritte or delete the old renamed file.
Example:
I have file name P00375 LIVAR rename to new folder with name P00375. but in a while I need to change original file P00375 LIVAR and save it and when I run script for rename and move It won't because error Destination file already exist. Is there any way to overwritte or delete the old file?
thaks for any suggestion
Martin
Offline
Is there any way to overwrite or delete the old file?
Yes, you can instruct ReNamer to overwrite existing files during a renaming operation. Go to Settings, Rename tab, enable "Overwrite files with new names" option. You should take extra care and double check what you doing, because overwritten files will be lost forever!
For the reference:
ReNamer:Program_settings#Rename_settings
Offline
Pages: 1