Can anyone advise on macros for pc rather than excel

tweacle

Rules violation
Joined
Nov 8, 2005
Messages
382
Ladies and Gents

First of all apologies if in wrong forum but donno if anyone can help.


I know you can do macros for Excel and Word but can you do macros that run on the PC?

I’m trying to get the PC to open “S:\CCTV Downloads\Downloads” and then sort the subfolders into date order. After that I want it to look for subfolders that had date created over 30 days ago and if so I need them deleted.

Is that possible?
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Sorting is irrelevant.

If you have folders that are over 30 days ago the folder simply needs deleting, sorting is not required.
You only need sorting if you want to display the remaining folders once the other folders have been deleted.
Sorting folders you are about to delete is inefficient.

Google batch files / MS-DOS commands
 
Upvote 0
You could do this in Excel VBA:

Code:
Public Sub DeleteOldFolders()

Const MyParentFolder = "S:\CCTV Downloads\Downloads"

Dim fso As Object
Dim parentFolder As Object
Dim subFolder As Object

Set fso = CreateObject("Scripting.FileSystemObject")
Set parentFolder = fso.GetFolder(MyParentFolder)

For Each subFolder In parentFolder.SubFolders
    If subFolder.DateCreated < Date - 30 Then
        subFolder.Delete True
    End If
Next subFolder

End Sub

WBD
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,632
Latest member
jladair

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top