You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Download folder on Mac

i need a script or Automator to empty the download folder ( keep the last 30 days )


A procedure or step by step will be appreciate ;)


Thank you very much,


Stewart

iMac Line (2012 and Later)

Posted on Jul 3, 2021 3:06 PM

Reply
Question marked as Top-ranking reply

Posted on Jul 4, 2021 5:12 AM

Create in Automator a new Workflow with the following actions:


Get Specified Finder Items

Add the Downloads folder to it


Get Folder Contents

Check "Repeat for each subfolder found"


Filter Finder Items

Set "All" of the following are true

"Date last modified" "is not in the last" "30" "days"


Move Finder Items to Trash

7 replies
Question marked as Top-ranking reply

Jul 4, 2021 5:12 AM in response to MacLouds

Create in Automator a new Workflow with the following actions:


Get Specified Finder Items

Add the Downloads folder to it


Get Folder Contents

Check "Repeat for each subfolder found"


Filter Finder Items

Set "All" of the following are true

"Date last modified" "is not in the last" "30" "days"


Move Finder Items to Trash

Jul 5, 2021 10:29 PM in response to MacLouds

You can Save the Workflow as an Application (say, Cleanup.app) in the Application folder.


To schedule the application to run daily:


Add your app (Cleanup.app) to System Preferences -> Security & Privacy > Privacy > Accessibility


Create a User LaunchAgent in your Library (~/Library/LaunchAgents/). It's an XLM file (plain text).


Let's name it com.maclouds.cleanup.plist containing the following code:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.maclouds.cleanup</string>
    <key>ProgramArguments</key>
    <array>
        <string>/Applications/Cleanup.app/Contents/MacOS/Application Stub</string>
    </array>
    <key>RunAtLoad</key>
    <false/>
    <key>StartCalendarInterval</key>
    <array>
        <dict>
            <key>Hour</key>
            <integer>10</integer>
            <key>Minute</key>
            <integer>00</integer>
        </dict>
    </array>
</dict>
</plist>


The value in StartCalendarInterval is set at 10:00 AM. Change the time as you prefer.


In Terminal run the following command to load the just created LaunchAgent:


launchctl load ~/Library/LaunchAgents/com.maclouds.cleanup.plist


If you don't want to play with LaunchAgent and Terminal, there're some apps for scheduling, like Lingon.

Jul 6, 2021 10:28 PM in response to MacLouds

Hi Stewart,


this should run every Saturday at 10:00 AM:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.maclouds.cleanup</string>
    <key>ProgramArguments</key>
    <array>
        <string>/Applications/Cleanup.app/Contents/MacOS/Application Stub</string>
    </array>
    <key>RunAtLoad</key>
    <false/>
    <key>StartCalendarInterval</key>
    <array>
        <dict>
            <key>Hour</key>
            <integer>10</integer>
            <key>Minute</key>
            <integer>00</integer>
            <key>Weekday</key>
  			<integer>6</integer>
        </dict>
    </array>
</dict>
</plist>


Basically, only Weekday and 6 are added.


6 is Saturday, 7 is Sunday, 1 is Monday, etc.

Jul 7, 2021 5:58 AM in response to Marco Klobas

Thank you very much Marco to take the time to answer me, this resolve my problem with the Download Folder and Empty the trash automatically ;)


The fun thing about that is you made me want to learn more about scripts and automator, thank you !


I don't know where you from but if you come around Montreal (Quebec) in the future, let me know i will invite you to a very good restaurant :)


Stewart

Download folder on Mac

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.