| View previous topic :: View next topic |
| Author |
Message |
DW Contributor

Joined: 21 Mar 2003 Posts: 175 Location: UK
|
Posted: Tue Jul 13, 2004 9:26 pm Post subject: Numbering files help |
|
|
I have a folder of 1000 files and i want to rename them from 0001 to 1000
using vds to do all the work for me. how can i get it so the number start from 0001?
I have done it with 1 to 1000 but i want the leading zeros.
I also want to be able to say how many zeros will lead.
It this possible at all??? |
|
| Back to top |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Wed Jul 14, 2004 6:39 am Post subject: |
|
|
Yes, it's more than possible.... I'll be back in a few minutes with some code
for you  _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
| Back to top |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Wed Jul 14, 2004 7:03 am Post subject: |
|
|
The following is just a quick hack and I did not test this... So use
at your own risk and setup some test files to mess with before you
actually use this on the files you need to really rename.
| Code: | REM -- Create a list and fill it with a list of the files in the
REM -- directory you desire. Check to make sure the list has
REM -- something in it with the "IF" condition there.
LIST CREATE,1
LIST FILELIST,1,C:\temp\*.*
IF @text(1)
LIST SEEK,1,0
ELSE
WARN "Hey! There's no stinking files in the list! What be up wit dat!"
EXIT
END
REM -- List is good to go, so let's setup a couple of variables to keep
REM -- track of the count. First variable is the main counting variable.
REM -- The second one is the one used for padding the count with extra
REM -- number 0's.
%%Counter = 1
%%TempCounter = %%Counter
REPEAT
REM -- Now let's see if the count has all it's numbers. If not, let's
REM -- add 0's to the begining of the variable until there's a total
REM -- of 4 characters in the variable.
IF @unequal(@len(%%TempCounter),4)
REPEAT
%%TempCounter = "0"%%TempCounter
UNTIL @equal(@len(%%TempCounter),4)
END
REM -- Now the variable has the 4 digit number to use in renaming
REM -- the current file. Item 1 is the file to be renamed, @path(@item(1))
REM -- is holding the path for the new name, %%TempCounter holds the
REM -- 4 digit number for the file name and "."@ext(@item(1)) is the
REM -- file extension of the current file.
FILE RENAME,@item(1),@path(@item(1))%%TempCounter"."@ext(@item(1))
REM -- Ok, file has been renamed, now let's add a notch to the counters
REM -- and advance the list by 1 more and do it all again, and keep
REM -- doing it until we reach the end of the list and the last file
REM -- has been renamed.
%%Counter = @succ(%%Counter)
%%TempCounter = %%Counter
%%Null = @next(1)
UNTIL @null(@item(1))@not(@ok()) |
_________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
| Back to top |
|
 |
DW Contributor

Joined: 21 Mar 2003 Posts: 175 Location: UK
|
Posted: Wed Jul 14, 2004 8:35 am Post subject: |
|
|
Thats great, i managed to adjust it to my needs.
thank you |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|