If Dir (integrated, vbDirectory) & lt; & gt; "" Then The Shell "CMD/rd/s/q" c "" & amp; The integrated & amp; "" "" End the If
This command is used to delete all folders and files under the integrated and how to keep the latest 2 months, other all delete
Under the integrated will be . The 2019-05 . The 2019-09 . The 2020-06 The 2020-07 The 2020-08 The 2020-09 (the current month)
How to keep the 2020-08 and 2020-09 it two months, delete all other folder
Thank you!!!!!!
CodePudding user response:
According to judge what is the latest two months? The folder name? The folder creation time? The modification time of the latest file folder?
If the folder name, Year (Now) & amp; "-" & amp; Format (Day (Now), and "00") you can get the current monthYear (Now) & amp; "-" & amp; Format (Day (DateAdd (" m ", 1, Now)), and "00") can get last month Not these two, just delete