Son Bulucu klasörlerini liste olarak döndürmek için AppleScript


2

Finder'daki Son Klasörler menüsünün bir listesini döndürecek bir AppleScript yazmam gerekiyor . Bu menüyü açacak bir AppleScript istemiyorum - Son klasörleri liste olarak döndürmek için bir komut dosyasına ihtiyacım var.

Bu mümkünse, listeyi belki de bir iletişim kutusuyla göstererek göstermek bir fikir olabilir.

Mümkün mü?

Menü

Yanıtlar:


1

Bu MacScripter iş parçacığı , klasörleri diğer adlar olarak almak için bir komut dosyasına sahiptir, ancak 10.8'de çalışmasını sağlayamadım. Artık dosya veri anahtarı yok, ancak bu da işe yaramadı:

tell application "System Events"
    value of property list item "file-bookmark" of property list item 1 of property list item "FXRecentFolders" of contents of property list file "~/Library/Preferences/com.apple.finder.plist"
    try
        value of result
    on error err
        text 30 thru -4 of err
        (run script "«data alis" & result & "»") as alias
    end try
end tell

Düz metin değerlerini PlistBuddy ile yazdırabilirsiniz:

$ PlistBuddy -c 'Print FXRecentFolders:0:file-bookmark' ~/Library/Preferences/com.apple.finder.plist
book?0?Userslau?4A?x?iH???A?1M?$5DF7A03E-A7FB-3E80-B61D-F10CD8BF7B5D?/?6a0c3f51ea4eaf67e96c08fa9b69b93aee598f01;00000000;0000000000000020;com.apple.app-sandbox.read-write;00000001;01000002;000000000005ca9f;/users/lauri?????$Tt@d  ? ? ? ?  ?0 ???? ??,

Bu konudaki işleyici 10.7'de çalıştı ancak 10.8'de çalışmadı.

Sadece bazenamesine ihtiyacınız varsa, onlar için ayrı anahtarlar vardır:

tell application "System Events" to value of property list item "name" of property list items of property list item "FXRecentFolders" of contents of property list file "~/Library/Preferences/com.apple.finder.plist"


Cevabınız için teşekkürler. Yani bu son klasörlerin yollarını bir liste halinde geri almak mümkün mü? Verdiğin son örnek işe yarıyor ama dediğin gibi, sadece temelleri döndürür.
— Oliver Joseph Ash,

Sanırım mümkün, ama nasıl olduğunu bilmiyorum. Format, OS X’in her sürümünde değişiyor gibi görünüyor
— Lri

2

Bu komut dosyası, taban adlarını ve yol konumunu döndürür:

on findPathSeparator(theData, theFile)
    set pathSeparator to {0, 0, 0, 1, 1, 0, 0}
    set bytesFound to 0
    set bytesSearched to 0

    try
        read theFile from 0 for 0

        set numIterations to 0

        repeat (get eof theFile) times
            set theId to id of (read theFile from bytesSearched for 1)

            if theId is item (bytesFound + 1) of pathSeparator then
                set bytesFound to bytesFound + 1
            else
                set bytesFound to 0
            end if

            if bytesFound is (count of pathSeparator) then exit repeat

            set bytesSearched to bytesSearched + 1
        end repeat
    on error msg
        msg
    end try

    return bytesSearched - (count of pathSeparator)
end findPathSeparator

on getPathFromData(theData)
    set pathSeparator to {0, 0, 0, 1, 1, 0, 0}

    set theFile to (open for access POSIX file ("/tmp/get_recent_folders") with write permission)

    set eof theFile to 0

    write contents of theData to theFile

    set startPosition to findPathSeparator(theData, theFile)

    try
        read theFile from startPosition for 0

        set thePath to ""

        repeat
            set idList to id of (read theFile for 8)

            if (idList does not end with pathSeparator) then exit repeat

            set theLength to item 1 of idList

            set thePath to thePath & ("/" & (read theFile for theLength as «class utf8»))

            read theFile for (4 - theLength mod 4) mod 4
        end repeat
    on error msg
        msg
    end try

    close access theFile

    return thePath
end getPathFromData

tell application "System Events"
    tell property list file "~/Library/Preferences/com.apple.finder.plist"
        set dataItems to property list item "FXRecentFolders"'s property list items's property list item "file-bookmark"'s value
        set itemNames to property list item "FXRecentFolders"'s property list items's property list item "name"'s value
    end tell
end tell

set theOutput to ""

set itemNum to 1
repeat (count of dataItems) times
    set theOutput to theOutput & item itemNum of itemNames & "
" & getPathFromData(item itemNum of dataItems) & "
"
    set itemNum to itemNum + 1
end repeat

theOutput
Sitemizi kullandığınızda şunları okuyup anladığınızı kabul etmiş olursunuz: Çerez Politikası ve Gizlilik Politikası.
Licensed under cc by-sa 3.0 with attribution required.