Page 1 of 1
Pad Filename
Posted: Mon Mar 15, 2004 1:07 pm
by Guest
Is there a way to dynamically pad a filename with zeros to a certain length? For example, I have the following files in a folder:
123.txt
1234.txt
12345.txt
and I want the to all be 8 digits long like the following:
00000123.txt
00001234.txt
00012345.txt
Is there a way to do this with a filter. I have been trying to do this for the past 3 days and haven't been able to figure it out.
Thanks,
Garren
padding
Posted: Tue Mar 16, 2004 5:29 am
by pb
i would get the electronic listing of file names from the specified directory.
read the file names (as integers, without the suffix) using a c program
fprintf(fp,"%0.7d",number);
command would fix the file name to append with the needed number of zero's. In this case the total length would be 7 characters long. write it to a file with .bat extension and run it (incase of DOS) with a copy/move/rename command should solve the problem.
Unless you want to use MS Excel and save the 0's as a string instead of a number.
Posted: Tue Mar 16, 2004 1:11 pm
by DataMystic Support
Inside a restrict to filename filter, use a right justify filter to force the width, then replace all spaces with zeroes.
yep..
Posted: Fri Mar 26, 2004 6:48 pm
by jring
I've done this sort of things with Textpipe via Command line textpipe combo...
Dir "C:\director\of\choice" /b > C:\Dir.txt
The output in the file will be:
123.txt
1234.txt
12345.txt
You can now make a filter that creates a rename batch script which pads the filenames to 8 characters.
assuming your files are in C:\ root
Ren C:\123.txt 00000123.txt /q
J-