Jump to content
Macro Express Forums

Renaming File


MrBiggz

Recommended Posts

Well I guess not so much sequential, but looking to setup an automated move and rename a file macro to include the date in the file name.

 

I have a report that runs and kicks out a report and saves it to a PDF. What I want to do is have the macro run at some point during the night to move the file from one location to a shared location, but renaming the file with the day's date. I can move and rename the files no problem, but how do I set it up so when it's renaming the file, it knows today's date and rename's the file "Report_today's date.pdf"?

 

Hope this makes sense and it can be done.

 

 

 

Thanks,

 

Biggz

Link to comment
Share on other sites

Use the Text > Date/Time command to create a date string you can use in the filename. You can customize the format as well to be any order you like. I like the "2008-08-05 11.54" format personally. If you saved it to T1 it would look like "Report_%T1%.pdf"

Link to comment
Share on other sites

Use the Text > Date/Time command to create a date string you can use in the filename. You can customize the format as well to be any order you like. I like the "2008-08-05 11.54" format personally. If you saved it to T1 it would look like "Report_%T1%.pdf"

 

Thank you for the suggestion. I did get it to work, but did it a bit differently. Let me know if you see any problems with doing it this way:

 

=============================================

Copy file from C:\Reports\Report.pdf to G:\Group Reports\Report.pdf

Delay: 2 Seconds

Variable Set from File Date/Time (Get File Date/Time>Creation Date/Time <Month=N1/Day=N2/Year=N3>)

Rename File or Files to: G:\Group Reports\Report_%N1%-%N2%-%N3%.pdf

=============================================

 

It game me the desired naming convention I was looking for. Thoughts?

Link to comment
Share on other sites

That works. It's just not as elegant IMHO as there is only one variable to reference my way <DT:yyyy-mm-ddT:01:1:>. But your way is best if you want to use the file creation date instead of the time the macro fired. But in your post you said you wanted to use the "day's date" hence my suggestion.

 

Also when I create date strings for filing I like to put the date first and use a reverse order so that when you sort alphabetically they appear chronologically. If you have years of reports all the January reports appear in one block. For this reason I like to also pad my months and days EG 2008-08-06 instead of 2008-8-6. That way October doesn't appear after January. I used to use the creation date to view things chronologically but eventually a file is restored, moved or something to reset the creation date.

 

You can still use your method and pad as well. Just convert the integer to a string. Pad left with spaces for two. Replace space with zero. It's super simple, 3 lines, and you don't even need a condition.

<NMVAR:05:01:0:0000001:0:0000000><TMVAR2:14:01:00:002:000:><TMVAR2:21:01:00:000:000: 0>

Link to comment
Share on other sites

That works. It's just not as elegant IMHO as there is only one variable to reference my way <DT:yyyy-mm-ddT:01:1:>. But your way is best if you want to use the file creation date instead of the time the macro fired. But in your post you said you wanted to use the "day's date" hence my suggestion.

 

Also when I create date strings for filing I like to put the date first and use a reverse order so that when you sort alphabetically they appear chronologically. If you have years of reports all the January reports appear in one block. For this reason I like to also pad my months and days EG 2008-08-06 instead of 2008-8-6. That way October doesn't appear after January. I used to use the creation date to view things chronologically but eventually a file is restored, moved or something to reset the creation date.

 

You can still use your method and pad as well. Just convert the integer to a string. Pad left with spaces for two. Replace space with zero. It's super simple, 3 lines, and you don't even need a condition.

<NMVAR:05:01:0:0000001:0:0000000><TMVAR2:14:01:00:002:000:><TMVAR2:21:01:00:000:000: 0>

 

Yeah honestly I like your way better! :) I'll be switching to your suggestion as it is more of what I'm looking for! Thanks again!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...