Skip navigation

Apple script for selecting images in a folder

272 Views 6 Replies Latest reply: Oct 23, 2013 11:14 AM by Goody7 RSS
Goody7 Calculating status...
Currently Being Moderated
Oct 23, 2013 7:14 AM

Hello,

 

I want to use an apple script that, when run, will selet all the images in a folder that have the same unique image # (different counter #'s obviously).  In other words, I tell it to look for # XYZ and it selects them all for me.  I know it almost sounds pointless, as I could do a search querie, or arrange by name, date, etc ... But I'm often faced with folders of hundreds of images with very unique ID #'s that have no chronological-like delimiters and that don't include a date.  I.E., dk83928ijd9.0034.jpg.  I want to be able to simply run a script that quickly selects the ones I tell it to, so that I can then perform other scripts or actions on them, or simply drag them somewhere - or even use the apple script in an automator action.  Does that make sense?  Anyone have anything.  Thanks!!


C

GarageBand (Mac) '11, Mac OS X (10.6.8)
  • Frank Caggiano Level 7 Level 7 (22,760 points)
    Currently Being Moderated
    Oct 23, 2013 9:31 AM (in response to Goody7)

    Your question is a bit vague. This script will select all files in the Desktop that have the extension m4r

     

    tell application "Finder"

      activate

              set parentFolder to (path to desktop)

              select (every item of parentFolder whose name extension is "m4r")

    end tell


     

     

    This ine will select all files whose name contains "titlle"

     

    tell application "Finder"

      activate

              set parentFolder to (path to desktop)

              select (every item of parentFolder whose name contains "title")

    end tell


  • Frank Caggiano Level 7 Level 7 (22,760 points)
    Currently Being Moderated
    Oct 23, 2013 10:38 AM (in response to Goody7)

    So do you have any Applescript experience?  The scripts as show run on the Desktop folder

    set parentFolder to (path to desktop)

    To have it run on a different folder you could hardcode the path in or you could prompt the user for the folder to run on.

     

    There are a lot of good resourses for learning Applescript two off the top

     

    Introduction to AppleScript Language Guide

    macscripter.net

     

    Learn AppleScript is a very good book. Both as a tutorial and a refernce

     

    Google will find a lot more.

     

    regards

  • Frank Caggiano Level 7 Level 7 (22,760 points)
    Currently Being Moderated
    Oct 23, 2013 10:58 AM (in response to Goody7)

    changing the script to

     

    set searchText to "IMG"

     

    set parentFolder to choose folder with prompt "Select the folder:"

     

    tell application "Finder"

      activate

              select (every item of parentFolder whose name contains searchText)

    end tell


    will ask the user for the folder to search for files whose name contains 'IMG". Modify the IMG to what you are searching for. Just leave the quotes there.

     

    I highly recommend the book I linked to if you are serious about learning Applescript. The price is a bit steep but it does cover a lot of ground and is one of the few texts I've found that gives a good description of Applescript / Objective-C.

     

    good luck

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.