#1 2006-11-11 22:14

frost
Member
Registered: 2006-08-03
Posts: 5

Rename dublicate files

There are a files:
-----------------------------------
01 - Bad Attitude(2).mp3
01 - Bad Attitude.mp3
02 - The Unwritten Law(2).mp3
02 - The Unwritten Law.mp3
03 - Call Of The Wild(2).mp3
03 - Call Of The Wild.mp3
04 - Mad Dog(2).mp3
04 - Mad Dog.mp3
...
and so on
-----------------------------------
How to rename dublicate files
from: 01-file-name(2).mp3
to: _01-file-name(2).mp3

So I have to localize dublicate files to the list
-----------------------------------
_01 - Bad Attitude(2).mp3
_02 - The Unwritten Law(2).mp3
_03 - Call Of The Wild(2).mp3
_04 - Mad Dog(2).mp3
01 - Bad Attitude.mp3
02 - The Unwritten Law.mp3
03 - Call Of The Wild.mp3
04 - Mad Dog.mp3
-----------------------------------
Thanx.
Frost.
Russia.

Last edited by frost (2006-11-11 22:17)

Offline

#2 2006-11-12 15:42

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,440

Re: Rename dublicate files

Hi Frost!

Will there be cases when round brackets will occur in other parts of the filename, apart from "(2)" part?

Is it safe to assume that files that have round brackets will require a "_" prefixed to their names?

Offline

#3 2006-11-12 16:11

frost
Member
Registered: 2006-08-03
Posts: 5

Re: Rename dublicate files

When I copy many files from one folder to another, Total Commander automaticly renames dublicate files to view:
name_file(2).mp3 (or *(2).doc, *(2).jpg, *(2).mpg and so on...).
The dublicate name (in Total Commander) always have (2).
I want separate files by the name and delete them, but Total Commander couldn't make it.
I need rename files from view *(2).*   to any prefix before the name, like

1*.*
-*.*
a*.*

It doesn't matter what character before the name.
It could be any character. But renames only files with (2) suffix.

Frost.
Russia.

Offline

#4 2006-11-12 20:24

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,440

Re: Rename dublicate files

Here you go... below is the pascal script that will do that smile
It will put PREFIX to filenames that end with SUFFIX, you can change them to whatever you wish!

const
  PREFIX = '_';
  SUFFIX = '(2)';
var
  Pos: Integer;
  Name, S: WideString;
begin
  Name := WideExtractBaseName(FileName);
  Pos := WideLength(Name) - Length(SUFFIX) + 1;
  if Pos > 0 then
    begin
    S := WideCopy(Name, Pos, Length(SUFFIX));
    if S = SUFFIX then
      FileName := PREFIX + FileName;
    end;
end.

And here is the screenshot for your examples:

renamerprefixduplicatedud1.gif

Offline

#5 2006-11-12 21:12

frost
Member
Registered: 2006-08-03
Posts: 5

Re: Rename dublicate files

I have no words !!!!
It's work !!!
Respect to you, Denis.
I will never solve the problem without you.
Great program.
Thanx a lot.
I think thread must be closed.
Thanks again.
----------------------------------------
Frost, Russia.

Offline

Board footer

Powered by FluxBB