Jump to content
Macro Express Forums

Check Dates Of Sub Directories


doolysw
 Share

Recommended Posts

I've recently been trying to figure out how to have macro express check all the sub-directories under a directory, and delete all the ones with a creation date of 30 days or more. I've written my own macro to convert dates into julian dates, so that macro express can determine the differance in days, I just don't know how to get the program to determine the dates the sub-directories were created. Any one have any ideas?

Link to comment
Share on other sites

Ok, I think I figured it out. I name all of my sub-directories after the date they were created. One created today would be 10-3-2005. Then I wrote out two seperate scripts. On that converts the current date into a julian date. For example, today's date in julian date would be "2453646.5". Then it subtacts 31 from that, and then the second script converts it back into standard date which is 9-2-2005. Then I have the script delete the direcotry named 9-2-2005. The script will run at least daily, so it should always delete a directory when it turns 31 days old. The equation which I ripped off from this page, takes into account leap year and other variations. Also a word to any one using the equations on that page. The equation listed to convert the date to a julian number is wrong. Line C should read

 

C= 2 +(A-B)

 

Hope this helps some one else :D

Link to comment
Share on other sites

doolysw -

 

Here is another option for you:

 

Even though our PGM Functions Library contains Julian date calculation functions, I think they are not needed in your situation. Instead, imagine that you have a folder named "c:\temp\20051003" (obviously derived from Oct-03-2005). In order to delete it, today must be Nov-03-2005, or "20051103".

 

You could easily create a "20051103" string using the

Date/Time: Save "yyyymmdd" into %T1%

<DT:yyyymmddT:01:3:{P00031}{P00000}{P00000}{P00000}>

command, which generates a string from today's date, less 31 days. Then it is just a matter of using a Repeat with Folder loop to delete folders that are less than or equal to the string.

 

Instead of a using lot of string to number, number to string conversions, you are simply using the natural string comparison features built into Macro Express, or any other programming language.

Link to comment
Share on other sites

Yep, that's about 10,000 times simpler than what I was gonna do. Thanks :D

 

I really like this program, but I have 0 programming experiance, and very limited experiance with doing anything but keyboard emulation scripts in Macro Express. Gonna take a while, but I'll eventually get the hang of it. So far this board has been an invaluable source of information.

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...
 Share

×
×
  • Create New...