DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: File Renaming: Renumbering by Calculation (e.g. even, odd)?  (Read 6,555 times)

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • Plugin Coding Medal
    • Participated in NANY Challenge Three Times
File Renaming: Renumbering by Calculation (e.g. even, odd)?
« on: September 01, 2011, 11:53 AM »
Tried to figure out a simple way to renumber files of the form:

  000.ext, 001.ext, 002.ext, ...

as:

  000.ext, 002.ext, 004.ext, ...

or:

  001.ext, 003.ext, 005.ext, ...

What I ended up with was a multi-step process involving among other things, custom PascalScript via den4b's ReNamer.  For reference, the PascalScript part for even renumbering (plus prefix) was:

Code
var
  i: Integer;
  Number: String;
begin
  Number := Copy(FileName, 1, 3);
  i := StrToInt(Number);
  i := i * 2;
  FileName := 'a' + IntToStr(i) + WideCopy(FileName, 4, Length(FileName) - 3);
end.

This was followed by removing the prefix ('a') and appropriately zero-padding some of the filenames.

Does any one know of a simpler/easier way?  I also looked at Thunar's renaming feature and Metamorphose without coming up with anything useful.

Lashiec

  • Member
  • Joined in 2006
  • **
  • Posts: 2,374
Re: File Renaming: Renumbering by Calculation (e.g. even, odd)?
« Reply #1 on: September 01, 2011, 12:18 PM »
ReNamer can do it without using PascalScript:

[attach=#]

You might want to strip the numbers first, though:

[attach=#]

If you want to make it even more simpler, i.e. without using ReNamer or any other additional program (it's even easier with xplorer² mass rename), beats me.
« Last Edit: September 01, 2011, 12:24 PM by Lashiec »

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • Plugin Coding Medal
    • Participated in NANY Challenge Three Times
Re: File Renaming: Renumbering by Calculation (e.g. even, odd)?
« Reply #2 on: September 01, 2011, 12:24 PM »
Thanks!  The initial stripping seems to help quite a bit :)

Original address: https://www.donationcoder.com/forum/index.php?topic=27830.0