Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 7552 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies
Posted

I have had quite the dilemma trying to create a script to rename my files.

I have a folder every day with a group of files:

k19pe001.vit <---the "19" reprensents the day of the month

k19pe002.vit

k19pe003.vit

k19pe004.vit

{and so on...}

which i need to rename as

e 01.vit0317 <---the "0317" refers to the month (03) and the day (17)

e 02.vit0317

e 03.vit0317

e 04.vit0317

{and so on...}

i figured that I could wilcard out the "k19" prefix, as it changes daily, creating the new names of the files seems impossible, since "0317" stands for the month and the day, and I would have to alter the script daily to do this...

Is altering the script daily the only solution to my problem??

Thanks!

Posted

Assuming you have a variable in your script called "theFilename", you can add the date with these steps (programmed for learning, not optimization):

set RightNow to current date -- don't use (current date) more than once in a routine, time could tick while executing

copy ((offset of (the month of RightNow) in "jan feb mar apr may jun jul aug sep oct nov dec ") + 3) / 4 as integer to theMonth

if theMonth < 10 then copy "0" & theMonth as text to theMonth

copy day of RightNow to theDay

if (day of RightNow < 10) then copy "0" & theDay as text to theDay

set theFilename to theFilename & theMonth & theDay

This topic is 7552 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.