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
Pad Filename
Moderators: DataMystic Support, Moderators, DataMystic Support, Moderators, DataMystic Support, Moderators
padding
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.
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.
- DataMystic Support
- Site Admin
- Posts: 2227
- Joined: Mon Jun 30, 2003 12:32 pm
- Location: Melbourne, Australia
- Contact:
yep..
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-
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-