मैं खोजकर्ता आइटम को तेज़ी से खोजने के लिए इस स्क्रिप्ट को कैसे व्यवस्थित कर सकता हूं?


1

मेरे पास एक एपस्क्रिप्ट स्क्रिप्ट है, जो यह जांचती है कि मेरी प्लेलिस्ट में 11 मिनट से कम समय में 25 गाने हैं या नहीं और फिर नंबर बनाने के लिए किसी अन्य फ़ोल्डर से कुछ अस्थायी फ़ाइलों को मेरे Temp फ़ोल्डर में ले जाता है।

क्या कोई कारण है कि स्क्रिप्ट का "खोजक" बिट इतना धीमा है (इसे निष्पादित करने में लगभग 15 सेकंड लगते हैं)? कोई भी कोड वर्कअराउंड मैं यहां इस्तेमाल कर सकता हूं?

--this adds some songs if the playlist has less than 25 songs in it shorter than 11 mins
tell application "iTunes"
    set thePlaylist to playlist "Temp on iPod"
    --counts tracks less than 11 mins long
    count ((tracks of thePlaylist) whose duration is less than 665)
    set currentCount1 to result
    if currentCount1 is less than 25 then
        tell application "Finder"
            set theDestination to folder "Macintosh HD:Temp to be Listened to:temp on iPod:"
            get every file of folder "Macintosh HD:Temp to be Listened to:Temp:Short Temp (Small Files, <20mb):" whose kind is "MP3 audio"
            --this only gets the top level files
            set theMusic to result
            set myList to {}
            set theReplaceNo to (25 - currentCount1)
            repeat theReplaceNo times
                set currentFile to some item of theMusic
                copy currentFile to the end of myList
            end repeat
            --reveal every item of myList
            reveal myList
            delay 1.5
            move myList to theDestination
        end tell
    end if
end tell

क्या कोई मदद कर सकता है?

जवाबों:


1

मैंने अपने OSX 10.9.5 पर आपके कोड का परीक्षण किया और कोई समस्या नहीं देखी । इसमें 2 सेकंड का समय (देरी शामिल) था। इसलिए, मेरे लिए, कोड सही है।

OSX का आपका संस्करण क्या है? (शायद एक बग ...)

आप शायद पहले से ही जानते हैं, लेकिन स्क्रिप्ट को धीमा करने वाले भाग पर अधिक जांच करने के लिए, आप निम्न 2 कथनों का उपयोग कर सकते हैं:

-- Put this before the code you want to test :
set t to (time of (current date)) --Start timing operations

... your slow code here ...

-- Put this at the end of the code you want to test
set total to (time of (current date)) - t --End timing

क्षमा करें, मैं और अधिक मदद नहीं कर सकता।

हमारी साइट का प्रयोग करके, आप स्वीकार करते हैं कि आपने हमारी Cookie Policy और निजता नीति को पढ़ और समझा लिया है।
Licensed under cc by-sa 3.0 with attribution required.