You are not logged in.
I get a batch of files with numbers at the end- some will be name 1, some othername 02, and others yetanothername 003. I want to standardize the numbers so that they're all 3 digits long- name 001, othername 002, yetanothername 003. Any thoughts on how to do this?
Offline
Here are the steps to achieve that:
1) Add you files;
2) Right-click the table column and select "Name Digits" from the menu;
3) Click on the new "Name Digits" column to sort files by numbers in their names;
4) Add Strip rule to strip Digits from the filename;
5) Add Serialize rule, Incremental start 1 step 1, pad to length 3, at suffix;
Done! Here is a screenshot how it should look like before renaming:
Good luck
Offline
But I don't want to strip the numbers. The numbers may not be in order, but I still want them; think file 474, fileb 30, etc. Would that still work?
Offline
I'm not really sure what you are trying to do... can you explain it in more details? You could use export/import feature to show me a list of files, or a screenshot perhaps, but do explain what you are trying to do, giving examples of all different variations.
I can't help you if I don't know what you trying to achieve
Offline
Here goes:
I get a bunch of files twice a week. Each has a different name and a number in the title. They're digital comics, so I get:
Spider-Man 26
Hulk 434
Batman 2
etc. The numbers are not sequential in any way.
I want, when I'm done, for the files to look like this:
Spider-Man 026
Hulk 434
Batman 002
I want to keep the value of the number, just format it into a three-digit number with leading zeroes.
Does that make more sense?
One other thing- sometimes there are other numbers in the title. I don't want to change those other numbers. So I might get:
Spectacular Spider-Man v2 12
I don't want
Spectacular Spider-Man v002 012
but rather
Spectacular Spider-Man v2 012.
The number I want to format will always be the last number, and will always be at the end of the filename.
Offline
Use this code in PascalScript rule:
var
BaseName, Extension: string;
EndDigitsCount, I: Integer;
const
PAD_TO_LENGTH = 3;
procedure Inc(var A: Integer);
begin
A := A + 1;
end;
begin
EndDigitsCount := 0;
BaseName := WideToAnsi(WideExtractBaseName(FileName));
Extension := WideToAnsi(WideExtractFileExt(FileName));
for I:=Length(BaseName) downto 1 do
if IsWideCharDigit(BaseName[i])
then Inc(EndDigitsCount)
else Break;
if (EndDigitsCount > 0) and (EndDigitsCount <= PAD_TO_LENGTH) then
while EndDigitsCount < PAD_TO_LENGTH do
begin
Insert('0', BaseName, I+1);
Inc(EndDigitsCount);
end;
FileName := AnsiToWide(BaseName + Extension);
end.
I tried it on you examples:
Batman 2.txt
Hulk 434.txt
Spectacular Spider-Man v2 12.txt
Spider-Man 26.txt
And here is what comes out:
Batman 002.txt
Hulk 434.txt
Spectacular Spider-Man v2 012.txt
Spider-Man 026.txt
Just the way you wanted, I think
Offline
Yep, worked smooth as silk. Thanks for the help! Is there a PayPal address I can donate to? This program's awesome.
Offline
You are welcome! No, I don't have a PayPal account... so just enjoy using it, and spread the word
Offline
I will- thanks!
Offline
Hi Dennis, i've got a quick question for you regarding the pascalscript you posted above
You have these lines
var
BaseName, Extension: string;
EndDigitsCount, I: Integer;
........................
BaseName := WideToAnsi(WideExtractBaseName(FileName));
Extension := WideToAnsi(WideExtractFileExt(FileName));
for I:=Length(BaseName) downto 1 do
if IsWideCharDigit(BaseName[I])
then Inc(EndDigitsCount)
else Break;
After
BaseName := WideToAnsi(WideExtractBaseName(FileName));
BaseName should be the ANSI version of the unicode filename minus the extension
But then you use
if IsWideCharDigit(BaseName[I])
Shouldn't that return false as BaseName has already been converted to ANSI ?
I don't get it
Im not sure why the double checks are inplace, especially when I'd assume that any variety of IsWide should fail on a normal string?
I'm missing something :conf:
Offline