Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5850517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T13:09:05+00:00 2026-05-22T13:09:05+00:00

I’m very new to Applescript but have used other scripting languages over the last

  • 0

I’m very new to Applescript but have used other scripting languages over the last five years. I wrote a quick script that deletes some files/directories based upon file name matches and modification date. I did also test it a few times but I’m now under the impression that it is either badly written or dangerous, in the sense that it may delete more than necessary.

If you’re a pro scripter, can you please tell me if there’s anything wrong with my script? Is it unsafe? I’ve been led to believe that after speaking to a colleague who believes it’s done some ‘damage’.

Here’s the script:

set my_path to "Macintosh HD:Users:infmz:Backups"
    tell application "Finder"
        delete (every item of folder my_path whose modification date is less than ((get current date) - 4 * days) and name contains "backup_id")
        empty trash
    end tell

Specifically, I am trying to delete backup folders that are older than three days. All such folders contain the string “backup_id” in their names.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T13:09:06+00:00Added an answer on May 22, 2026 at 1:09 pm

    If this is the entirety of the script, then I would say the one “unsafe” item that really jumps out to me is that you are not parsing the folder path to ensure the script isn’t being directed to a vital folder, like “Macintosh HD:System:” or “Macintosh HD:Library:”.

    The other thing is that I don’t think the script does a good enough job parsing files before deleting. This is more a matter of approach, but if it were me, I would generate a list of initial target files first (see “Get full directory contents with AppleScript”), and then parse that list for actual targets for deletion.

    Also, I would generate a log of actions taken and remove the “empty trash” command to allow the user a chance to double-check the actions of the script before final deletion.

    It would be helpful to describe what damage was observed by the other user.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
this is what i have right now Drawing an RSS feed into the php,
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.