2

ファイルのグループを強調表示してそれらから変更日を取得し、最新の日付でファイルを強調表示/選択/ラベル付けするアクションを作成する方法を知りたいです。

更新:私はそれをさらに進めたので、Applescriptでそれをやりたいです。これが私がこれまでに持っているものです

set dateList to {}
tell application "Finder"
    set inputList to get selection
    repeat with i from 1 to count (inputList)
        set end of dateList to get modification date of item i of inputList
    end repeat
end tell

dateList

--Compare section...

set boolList to {}
set j to 1
repeat with i from 1 to count (dateList)
    if i is (count (dateList)) then
        set j to 0
    end if
    set end of boolList to item i of dateList > item (i + j) of dateList
end repeat

boolList
4

4 に答える 4

2

ディックはそれを理解しましたが、私は何かを修正して、ポップアップの代わりにファイルにラベルを付けるようにしました。

set dateList to {}
tell application "Finder"
    set inputList to get selection
    repeat with i from 1 to count (inputList)
        set end of dateList to get modification date of item i of inputList
    end repeat
end tell

--Compare section...

set theResult to item 1 of inputList as alias
set theResultDate to item 1 of dateList
set modDate to item 1 of dateList
repeat with i from 1 to count (inputList)
    if dateList's item i > modDate then
        set modDate to dateList's item i
        set theResult to item i of inputList as alias
        set theResultDate to item i of dateList
    end if
end repeat

--Display Result…

--display alert "Most recently modified file in selection:" message "" & theResult & "
--" & theResultDate
tell application "Finder" to set label index of (theResult as alias) to 6

これにより、緑色のラベルが付けられます。インデックス番号1〜8で別の色のフィドルが必要な場合、それらは明らかに順序がありません. また、Finder は、開いている他のウィンドウでの選択をカウントしないほど賢いようです。

ありがとう!

最後に、右クリック アイテムとして使用できるようにするには、Automator を開き、サービスを作成し、ファイル/フォルダーでこれを使用するように上部で選択し、そこに Run Applescript をドラッグし、スクリプトを貼り付けて保存します。これで、右クリックで使用できるようになります。1 つの欠点は、何かがラベル付けされるまでファイルを選択したままにする必要があるように見えることです。そのため、動作中にクリックする必要はありません。

于 2013-05-06T04:58:06.290 に答える
1

必要以上に複雑にしています:

tell application "Finder" to reveal item 1 of (sort (get selection) by modification date)
于 2013-05-06T11:32:22.933 に答える
0

10.7 および 10.8 にはバグがあり、実行方法によっては、提案されたすべてのスクリプトがほとんど使用できなくなる可能性があります。新しい Finder ウィンドウを開いていくつかのファイルを選択するとtell application "Finder" to selection、最前面のウィンドウ (または空のリスト) の後ろにあるウィンドウで選択されたファイルが返されます。

1 つの回避策は、フォーカスを別のアプリケーションに切り替えてから戻すことです。

activate app "SystemUIServer"
tell application "Finder"
    activate
    set label index of item 1 of (sort selection by modification date) to 6
end tell

次のように、Run AppleScript アクションを使用して Automator サービスを作成することもできます。

on run {input, parameters}
    tell application "Finder"
        sort (input as alias list) by modification date
        set label index of item 1 of result to 6
    end tell
end run
于 2013-05-06T12:12:51.167 に答える