Dr. Demento
Member
I posted this at Mr. Excel but no one was able to provide what I was looking for. I'm hoping that folks here might have some ideas.
I create a timestamped backup of my Personal.xlsb (filename & "_yyyymmdd_hhss") everytime I save it. As you can imagine, this leads to a lot of versions each day. Sometimes I need to go back a few hours within the day, so creating the backups using the date only doesn't work.
Could someone give me some pointers how I might loop thru all files within a specified folder, and deleting all files EXCEPT the last saved file of each individual day. I'd likely run this once a week, so I keep the number of files manageable.
I'm not looking to immediately delete all files at the end of each day; instead, I would run this once a week. Given this, the sub would need to cycle thru each individual date, identify the last time for each date, and delete (or move; probably safer than outright deleting) the other files within that date.
For example, if the following files were in a folder:
Personal.xlsb_20160914_1023.bak
Personal.xlsb_20160914_1700.bak
Personal.xlsb_20160915_1156.bak
Personal.xlsb_20160915_1444.bak
Personal.xlsb_20160915_1603.bak
All files except the two below would get moved to another folder:
Personal.xlsb_20160914_1700.bak
Personal.xlsb_20160915_1603.bak
I would imagine that it would consist of two loops - the outside loop to cycle thru the date portion of the filename and the inside loop to cycle thru the times within that date. Would the inner loop use Step -1 (start at the last time, and move/delete any time less than the daily max time)? I just can't figure out how to construct loops that look in the middle of a string and evaluate/discriminate.
Any thoughts would be most appreciated. Thanks y'all.
__________________________________________________________________
I create a timestamped backup of my Personal.xlsb (filename & "_yyyymmdd_hhss") everytime I save it. As you can imagine, this leads to a lot of versions each day. Sometimes I need to go back a few hours within the day, so creating the backups using the date only doesn't work.
Could someone give me some pointers how I might loop thru all files within a specified folder, and deleting all files EXCEPT the last saved file of each individual day. I'd likely run this once a week, so I keep the number of files manageable.
I'm not looking to immediately delete all files at the end of each day; instead, I would run this once a week. Given this, the sub would need to cycle thru each individual date, identify the last time for each date, and delete (or move; probably safer than outright deleting) the other files within that date.
For example, if the following files were in a folder:
Personal.xlsb_20160914_1023.bak
Personal.xlsb_20160914_1700.bak
Personal.xlsb_20160915_1156.bak
Personal.xlsb_20160915_1444.bak
Personal.xlsb_20160915_1603.bak
All files except the two below would get moved to another folder:
Personal.xlsb_20160914_1700.bak
Personal.xlsb_20160915_1603.bak
I would imagine that it would consist of two loops - the outside loop to cycle thru the date portion of the filename and the inside loop to cycle thru the times within that date. Would the inner loop use Step -1 (start at the last time, and move/delete any time less than the daily max time)? I just can't figure out how to construct loops that look in the middle of a string and evaluate/discriminate.
Any thoughts would be most appreciated. Thanks y'all.
__________________________________________________________________
Mod edit : thread moved to appropriate forum !