• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Trying to open just three items at a time
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trying to open just three items at a time


  • Subject: Re: Trying to open just three items at a time
  • From: Stan Cleveland <email@hidden>
  • Date: Mon, 08 Mar 2010 17:55:48 -0800
  • Thread-topic: Trying to open just three items at a time

On 3/8/10 1:35 PM, "Ken Latman" wrote:

> I trying to think if there is a way to script Photoshop to batch process a
> large group of files for HDR photography.

<snip>

> The script would have to have you select a source folder and destination
> folder; find only (in my case) .dng files in alphabetical order. Select the
> first three; merge to HDR (this might become an expanded series of tasks);
> save as a new file to the destination folder with a starting sequence
> number; repeat for the next three and continue to repeat until done.
>
> I"m not a scripting pro and I have only gotten so far as designating a
> source folder, destination folder, counting the number of files in the
> source folder, determining whether or not total number of files in the
> folder is a multiple of 3.
>
> set dng_folder to choose folder with prompt "Where are the DNGs?"
> set hdr_folder to choose folder with prompt "Select a target folder for
> HDRs:"
>
> tell application "Finder"
>     -- make an item list from your identified folder
>     set itemList to name of every file of folder dng_folder
>
>     set fileCount to count of items in itemList
>     (*
>     set multipleThree to (fileCount / 3)
>      if class of result is real then
>         display dialog "this is not a multiple of 3"
>     end if
>     *)
>
> end tell
> item 3 of itemList

Hi Ken,

Here's some code that might help you with splitting up the list of files.
The handlers are generalized to work with lists and subgroups of any size
and list elements of any class.

HTH,
Stan C.


tell application "Finder"
  set itemList to name of every file of folder dng_folder
end tell
if listIsDivisibleBy(3, itemList) then
    set subGroupList to splitListIntoGroupsOf(3, itemList)
    -- process the files
    repeat with i from 1 to (count subGroupList)
        set thisGroup to item i of subGroupList
        tell application "Finder" -- open 3 files simultaneously
            open (files of folder dng_folder whose name is in thisGroup)
        end tell
        -- do stuff here
    end repeat
else
    display dialog "List count is not a multiple of 3."
end if

(***************  HANDLERS FOLLOW  ***************)

on listIsDivisibleBy(groupSize, theList)
    if (count theList) mod groupSize is 0 then return true
    return false -- default
end listIsDivisibleBy

on splitListIntoGroupsOf(groupSize, theList)
    set listCount to count theList
    set remainder to listCount mod groupSize
    set subGroupList to {}
    repeat with i from groupSize to listCount by groupSize
        set subGroup to {}
        repeat with j from (groupSize - 1) to 0 by -1
            set end of subGroup to item (i - j) of theList
        end repeat
        set end of subGroupList to subGroup
    end repeat
    if remainder > 0 then
        set subGroup to {}
        repeat with i from 1 to remainder
            set end of subGroup to item (listCount-remainder+i) of theList
        end repeat
        set end of subGroupList to subGroup
    end if
    return subGroupList
end splitListIntoGroupsOf


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Trying to open just three items at a time (From: Ken Latman <email@hidden>)

  • Prev by Date: Re: multi input form
  • Next by Date: Resize JPG files and keep the clipping path
  • Previous by thread: Trying to open just three items at a time
  • Next by thread: Re: Trying to open just three items at a time
  • Index(es):
    • Date
    • Thread