Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
OrganizationEventAdvent CalendarQiitadon (β)
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.




16 space: CMYK
16 profile: Japan Color 2011 Coated
16 format: psd
16 bitsPerSample: 8


use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

tell application "Finder"
    set {myFiles, myResList, myResultText, myResult, myDelim} to {{}, {}, "", "", "\" \""}
    set mySel to selection

    repeat with i in mySel
        set myPath to POSIX path of (i as alias)
        if (class of i) is folder then
            set myResList to myResList & digFolder(myPath) of me
            set myResList to myResList & myPath
        end if
    end repeat

    set myResultText to "\"" & retStrFromArrayWithDelimiter(myResList, myDelim) of me & "\""
    set myResult to "ファイル数:" & (count of myResList) & return & (do shell script "sips -g format -g space -g profile -g bitsPerSample " & myResultText & " | sed -e 's:^/.*$::g' -e '/^$/d' | sort -br | uniq -c | sed -e 's:^ *::g' ")
    log myResult -- 単体で使うにはdisplay alertなどにする
end tell

(* ここからサブ *)

on digFolder(myPath)
    set digItem to do shell script "find " & quoted form of myPath & " -type f ! -name '.*' | sed -e 's://:/:g'"
    return every paragraph of digItem
end digFolder

-- 以下ぴよまるより

on retStrFromArrayWithDelimiter(aList, aDelim)
    set anArray to current application's NSArray's arrayWithArray:aList
    set aRes to anArray's componentsJoinedByString:aDelim
    return aRes as text
end retStrFromArrayWithDelimiter


Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Help us understand the problem. What are the problem?