5 Replies Latest reply: Jan 12, 2013 2:53 PM by Globalksp
Globalksp Level 1 Level 1 (0 points)

Happy New Year all (those of us on the gregorian calendar anyway)!

 

This question revolves around my hope/desire that there are ways for either scripts or automator to perform repetative tasks for me. My knowledge of OS doesn't extend into these two features and while I've been reading up on them, I'm still a bit lost. I have no idea if any of these actions can be automated, I'm merely hoping. 

 

What I'd like to happen:

 

  • Folder Creation and Naming: I routinely need to create multiple, empty, "shot folders" (for photoshoots) that are nested within other folders.
    • Example: /desktop/ShootName/Capture/Shot01, Shot02, Shot03, Shot04, etc... often times into the 10's of folders.
    • I'd be happy with the creation of the folders alone. I can rename with renaming apps (Rename, being my app of choice)
  • Open Three Finder Windows: Three windows open and scale themselves to fit horizontally on the screen (one atop the other atop the other)
    • Screen shot 2013-01-01 at 3.23.00 PM.jpg

 

So far that's all I've found that I could need at the moment. I realize the hangups for each (i.e. how to know how many folders to create on each instance) and I'm sure there are things I haven't foreseen.

 

Any knowledge or resources to other helpful scripts/actions are appreciated!

 

-K


MacBook Pro (15-inch Early 2011), Mac OS X (10.6.8), Mid-2011, 500GB, 2.2GHz i7, 8GB
  • 1. Re: Help With Finder Scripts / Automator
    Jacques Rioux Level 4 Level 4 (1,960 points)

    Hi,

     

     

    Here is an AppleScript to start.

    ------------------

    set screenBounds to {0, 44, 1920, 1640} -- screen rect, change according to your needs.
    set aName to "Shoot" -- some folder name to rename each created folder
    set targetFolder to choose folder with prompt "Select the directory to create folders"
    display dialog "How many folders you want to create." default answer "10"
    set n to (text returned of the result) as integer
    
    ---** create folder **---
    repeat with i from 1 to n
        if i < 10 then
            set x to aName & "0" & i
        else
            set x to aName & i
        end if
        tell application "Finder" to make new folder at targetFolder with properties {name:x}
    end repeat
    
    set nWind to 3 ---**  create Finder Window **---
    tell screenBounds to set {h, b} to {((item 4) - (item 2) + ((22 * nWind) + 22)) div nWind, it}
    set item 4 of b to h
    repeat with i from 1 to nWind
        tell application "Finder" to tell (make new Finder window)
            set target to targetFolder
            set bounds to b
        end tell
        set h1 to item 4 of b
        tell b to set {item 2, item 4} to {h1 + 22, h1 + h - 22}
    end repeat
    

     

    Since I don't have enough information, the script will not be as you wish, so please don't hesitate to ask the necessary additions or change to this script.

  • 2. Re: Help With Finder Scripts / Automator
    Globalksp Level 1 Level 1 (0 points)

    This is great, Jacques. When I have a moment I'll give it a run and let you know what's what.

     

    Cheers,

     

    K

  • 3. Re: Help With Finder Scripts / Automator
    Globalksp Level 1 Level 1 (0 points)

    Just ran the scripts.

     

    Thank you very, very much. I wasn't expecting operational scripts to be delivered!

     

    The three window script (the 2nd one) did throw back an error, and I've tried tweaking it but had no luck. What information do you need? Screen/window size? Where does that info go in the script?

     

    Screen shot 2013-01-02 at 11.20.18 AM.jpg

     

    Message was edited by: Globalksp

  • 4. Re: Help With Finder Scripts / Automator
    Jacques Rioux Level 4 Level 4 (1,960 points)

    Hi,

     

     

    Globalksp wrote:

     

    Just ran the scripts.

     

    The three window script (the 2nd one) did throw back an error

     

    The firsts lines of script are needed, because I thought it was for the same script.

     

     

    Here is a script for Finder windows only:

    --------------

    set r to do shell script "/usr/sbin/system_profiler −detailLevel mini SPDisplaysDataType | awk '/Resolution/{print $2 \" \" $4}'" -- get display's width and height
    set {x, y, w, h} to {0, 22, (word 1 of r) as integer, (word 2 of r) as integer}
    set targetFolder to choose folder with prompt "Select a directory to set the target of each Finder window"
    
    set nWind to 3 ---**  the number of  Finder Window to create **---
    tell (h div nWind) to set {h, a} to {it, it}
    repeat with i from 1 to nWind
        tell application "Finder" to tell (make new Finder window)
            set target to targetFolder
                set bounds to {x, y + 22, w, h}
        end tell
        set {y, h} to {h, h + a}
    end repeat
    

     

     

    If you want the default window's target:

    ----------------

    set r to do shell script "/usr/sbin/system_profiler −detailLevel mini SPDisplaysDataType | awk '/Resolution/{print $2 \" \" $4}'" -- get display's width and height
    set {x, y, w, h} to {0, 22, (word 1 of r) as integer, (word 2 of r) as integer}
    set nWind to 3 ---**  the number of  Finder Window to create **---
    tell (h div nWind) to set {h, a} to {it, it}
    repeat with i from 1 to nWind
        tell application "Finder" to tell (make new Finder window)
            set bounds to {x, y + 22, w, h}
        end tell
        set {y, h} to {h, h + a}
    end repeat
    
  • 5. Re: Help With Finder Scripts / Automator
    Globalksp Level 1 Level 1 (0 points)

    Perfect!

     

    Used them on 2 shoots now and will not leave home without them on a thumb drive.

     

    Many, many thanks!