#21 2007-05-16 21:01

bobyang
Member
Registered: 2007-05-08
Posts: 33

Re: rename the same filename but different extension

thank you! this works very well.

however, I went back to the old question again:

1. how can I avoid the extension check?
eg. I have"c:\user1\user1-text.jgp" and "c:\user1-text.txt"
if I put "c:\user1-text.txt" into rule, how can I make it produce "c:\user1\user1-text(2).txt" instead of "c:\user1\user1-text.txt" (add (23..) without checking the extensions)

2. "&" problem. it works by not putting to the folder but the filename adds "(2)" the end if nothing gets changed
eg. I have"c:\user1&user2-text.txt" and "c:\user1&user2-text2.[KTV].txt"
the preview came up like this:
"c:\user1&user2-text.txt" -> "c:\user1&user2-text(2).txt"  (this is not right because it should stay the same)
"c:\user1&user2-text2.[KTV].txt" -> "c:\user1&user2-text2.txt"  (I have a rule to remove ".[KTV]" so this is correct result)

sorry about asking all these questions...

Last edited by bobyang (2007-05-16 21:06)

Offline

#22 2007-05-17 12:19

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

Re: rename the same filename but different extension

Huh.. all these rules... it hearts my head already wink

I think I managed to satisfy every single problem that you mentioned, plus to latest ones:
1) it will check the destination path, if a similar file with different extension exists.
    NOTE: it will only look for 2 to 3 characters extension, refer to '.???' part of code,
    because if I use '.*' it will mistakenly match ".[KTV].txt" in "user1&user2-text2.[KTV].txt".
2) if file hasn't changed been changed - do not serialize.

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;
  if FileName <> WideExtractFileName(FilePath) then
  while Exists(Path + NewName) or
    WideFileExists(Path + NewName + '.???') or 
    WideFileExists(Path + NewName + '.??') do
  begin
    NewName := Name +'(' + IntToStr(Counter)+')'; 
    Counter := Counter + 1;
  end;
  Add(Path + NewName);
  FileName := NewName + Ext;
end.

renamercomplexkaraokevh0.gif

Offline

#23 2007-05-17 18:31

bobyang
Member
Registered: 2007-05-08
Posts: 33

Re: rename the same filename but different extension

thank you thank you thank you!!
everything works great!
thank you again!

PS. I add "WideFileExists(Path + NewName + '.????') or " because they may have extension with 4 charaters. thank you!

Offline

#24 2007-05-17 19:21

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

Re: rename the same filename but different extension

Glad that it finally works! big_smile

To finish it up, you can create a shortcut like:
"C:\Program Files\ReNamer\ReNamer.exe" /preset "KTV filename Clean up"

This will load the preset into ReNamer when it is launched.

Offline

#25 2007-05-18 03:52

bobyang
Member
Registered: 2007-05-08
Posts: 33

Re: rename the same filename but different extension

den4b wrote:

Glad that it finally works! big_smile

To finish it up, you can create a shortcut like:
"C:\Program Files\ReNamer\ReNamer.exe" /preset "KTV filename Clean up"

This will load the preset into ReNamer when it is launched.

thank you! this is a good idea too!

i created an video to teach them how to use it in youtube. I also like them to start using this software and create their own rule by themslves big_smile. so they will not how powerful it is!
The only thing.. a lot of them are "afraid" of reading english.. sad... but i think as slong as they follow the video or I pre-set as the command then they don't need to worry too much about english.

by the way, do you think it is ok to release beta version to them?
thanks

Last edited by bobyang (2007-05-18 03:52)

Offline

#26 2007-05-18 05:48

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

Re: rename the same filename but different extension

Yes, it is fine to give the beta version.

"Beta" simply stands for latest development version, it doesn't necessarily mean "un-stable". My "Beta" versions are usually as stable as the normally released versions, unless I implement something really big or change something radically, which isn't the case right now. Look at "What's New" section for more info.

Offline

Board footer

Powered by FluxBB