Recursively delete certain file types from folder

Discussion in 'Mac Basics and Help' started by max6166, Apr 18, 2011.

  1. max6166 macrumors newbie

    Joined:
    Jun 14, 2010
    Location:
    Toronto, Canada
    #1
    I have a folder from which I regularly have to delete a few different types of files. It is a little tedious to do manually, so I was hoping there might be a better solution.

    Ideally, I am hoping for a command that I could access from the context menu that would recursively find and delete any files with specific extensions.

    Thanks.
     
  2. mulo, Apr 18, 2011
    Last edited: Apr 18, 2011

    mulo macrumors 68020

    mulo

    Joined:
    Aug 22, 2010
    Location:
    Behind you
    #2
    you could make a simple applescript to remove them, you could then have your mac run that script every time you log in so you don't have to worry about it.

    tell em what file types and from what folder you want to remove and ill write it for you if you want.
     
  3. max6166 thread starter macrumors newbie

    Joined:
    Jun 14, 2010
    Location:
    Toronto, Canada
    #3
    Thanks very much for the offer, Mulo. I managed to hack some AppleScript I found which is pretty close to what I need though.

    I could use some help debugging it though. For some reason, it doesn't seem to delete ".srr" files. But it deletes all the other file types just fine...?

    My suspicion is that the problem is actually not with the script, but lies somewhere else. I have no idea what it could be though...

    Here is the script I am using:

    ========
    tell application "Finder"
    set f to (files of entire contents of folder ((path to home folder as Unicode text) & "Downloads:_Incoming:") whose name extension is "sfv" or name extension is "par" or name extension is "par2" or name extension is "nzb" or name extension is "srr") as alias list
    repeat with aFile in f
    delete aFile
    end repeat
    end tell

    =========
     

Share This Page