#1 2011-12-01 12:08

Imagoid
Member
Registered: 2011-12-01
Posts: 2

Strip leading zeros

Hello there!

I would like to strip the leading zeroes from my six-digit file names.  Eg 000001, 003241, 097845, 243546 would become 1, 3241, 97845, and 243546.  I did search in the forum and in Renamer itself - I think it might be in RegEx - but couldn't see how to do it.  Great program & thanks in advance for any assistance.

Offline

#2 2011-12-01 12:51

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Strip leading zeros

Hi and welcome.

FROM:
000001.ext
000011.ext
000201.ext
003001.ext
003241.ext
040001.ext
097845.ext
243546.ext

TO:
1.ext
11.ext
201.ext
3001.ext
3241.ext
40001.ext
97845.ext
243546.ext

You can really use RegEx.
The pattern is easy in ReNamer because you don't have to match the whole string but only what you really need:

1) RegEx: Replace expression "^0+" with "" (skip extension)

Explanation:
^ --> match at start of string
0 --> match one literal digit '0'
+ --> match one-or-more of the pattern right before, here the '0'

So we will match one or more of leading zeros, if any, and replace them with nothing, meaning removing them.

HTH? big_smile


Note:
you can use "Preset > Save as..." to store that rule for later use
or use an PascalScript saved to an file into the Scripts sub-folder for the very same purpose:

begin
//ReplaceRegEx(Input,'Find', 'Replace', CaseSensitive, UseSubstitution)
  FileName :=  ReplaceRegEx(FileName, '^0+', '', False, False);
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

#3 2011-12-02 14:51

Imagoid
Member
Registered: 2011-12-01
Posts: 2

Re: Strip leading zeros

Hi Stefan

Thanks, that works perfectly!  What a powerful program.

Just typing in three characters and a few clicks to do the entire job!  Remarkable.

Best wishes

PS Your examples are better than mine, aren't they - it was of course important to retain the non-leading zeroes as you showed.  cool

Offline

Board footer

Powered by FluxBB