Image File Renaming

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
daniel
Junior Coder
Posts: 32
Joined: Mon Apr 25, 2005 5:04 pm

Image File Renaming

Post by daniel » Wed Dec 19, 2007 4:44 pm

I have an issue trying to copy and rename a few files. I'm trying to copy and rename a few thousand Tif file into a new folder and rename them.

Let>y=00000001

Repeat>x
CopyFile>%Path%\001%RollNumber%%x%.tif,C:\WM\%RollNumber%\%y%\0\00\%ImageName%.tif

Let>y=y+1
Until>x=1000


This is a sample code and it works fine with the first image and it renames 00000001.tif.

But when I get to the second image it just name it 2.tif.

I know that the problem come when I increment the y by 1, so how can I get it to format with all of the zero infront of the images name? I want the images to be named:

00000001.tif
00000002.tif
00000003.tif
00000004.tif etc...


Any help here would be greatly appreciated. Thanks in advance,

-daniel

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Dec 19, 2007 5:07 pm

2 is a number. 0000002 is a string. You just need to convert from the loop counter to a string. You can do this:

VBSTART
VBEND

//e.g. with x = 2
Let>x=2

VBEVal>Right("00000000" & %x%,8),strX
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

daniel
Junior Coder
Posts: 32
Joined: Mon Apr 25, 2005 5:04 pm

Post by daniel » Wed Dec 19, 2007 6:00 pm

It worked..thanks.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts