doolysw Posted September 30, 2005 Report Share Posted September 30, 2005 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? Quote Link to comment Share on other sites More sharing options...
floyd Posted September 30, 2005 Report Share Posted September 30, 2005 Are you wanting to compare the actual creation date of a sub-folder or the name of the sub-folder? Quote Link to comment Share on other sites More sharing options...
doolysw Posted October 3, 2005 Author Report Share Posted October 3, 2005 The creation date would be the best, but it would be possiable to name the folder the date, and have it read that if necessary. Quote Link to comment Share on other sites More sharing options...
doolysw Posted October 3, 2005 Author Report Share Posted October 3, 2005 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 Quote Link to comment Share on other sites More sharing options...
floyd Posted October 3, 2005 Report Share Posted October 3, 2005 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. Quote Link to comment Share on other sites More sharing options...
doolysw Posted October 4, 2005 Author Report Share Posted October 4, 2005 Yep, that's about 10,000 times simpler than what I was gonna do. Thanks 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.