एप्सस्क्रिप्ट हाई सिएरा पर काम नहीं कर रहा है


0

मैंने छवियों के एक समूह का नाम बदलने और फ़ाइल नामों और आयामों के साथ एक पाठ फ़ाइल बनाने में मदद करने के लिए एक एपलस्क्रिप्ट कोड बनाया ताकि हम ईमेल में प्रोग्राम करने के लिए किसी अन्य टीम को भेज सकें।

जब मैं सिएरा पर था तब कोड पूरी तरह से ठीक काम करता था, लेकिन जब से मैंने हाई-सिएरा को अपडेट किया तब से यह सभी फाइलों का नाम नहीं बदलता है। आमतौर पर हमारे ईमेल में 4-20 चित्र होते हैं जिन्हें नाम बदलने की आवश्यकता होती है, लेकिन नए macOS के साथ स्क्रिप्ट 2 छवियों का नाम बदल देगी और इस संदेश के साथ बंद हो जाएगी

**error "Can’t get item 1 of {}." number -1728 from item 1 of {}**

यहाँ कोड है, लेकिन समस्या में होता है

set h to (item 1 of dimensions) --/ dpi_to_dpmm -- works out pixel height as mm

अगर कोई मदद कर सकता है तो मैं इसकी सराहना करूंगा।

    --PopUp Window to select folder of files needing to be renamed
set iFolder to (choose folder with prompt "Select Folder")
--Sets folder path to readable location
set fPath to POSIX path of iFolder
--Sets folder path parent folder
set pPath to POSIX path of ((iFolder as text) & "::")
--removes listing invisible files
set fContent to list folder iFolder as list without invisibles
--seperates file name from extension
set text item delimiters to "."


tell application "Finder"
    --set gPath to fPath as string
    set all_files to every item of (iFolder) as list

    -- Multiple Selections
    set theDeviceList to {"Regular", "Luxury", "Holiday"}

    set theDevice to (choose from list theDeviceList with title "Device Selection" with prompt "Choose a Naming Convention:")

    set choices to the result as string
    -- Multiple Selections

    -- Begin Normal Email
    if choices is equal to "Regular" then
        -- Normal Email

        set new_FirstnameCol1 to "row"
        set new_LastNameCol1 to "-1col1image-responsive-image"

        set new_FirstnameCol2 to "row"
        set new_LastNameCol2 to "-2col2images-responsive2-image"

        set new_FirstnameCol3 to "row"
        set new_LastNameCol3 to "-3col3images-responsive2-image"

        --**Counter Begins
        --1 Column Counter
        set col1 to 1
        --2 Column Counter
        set col2 to 0
        --3 Column Counter
        set col3 to 0
        --Keeps count of all grouped columns
        set columnCounter to 0
        --Numbering convention to file name
        set universalCounter to 0
        set oopsCounter to 0
        --**Counter Ends

        repeat with i from 1 to the count of all_files
            --using our index, we select the appropriate file from our list
            set universalCounter to i - columnCounter - oopsCounter
            set this_file to item i of all_files
            set file_name_count to text items of (get name of this_file)
            set {itemName, itemExtension} to {name, name extension} of this_file

            set source_file to item i of fContent
            set fName to do shell script "basename " & quoted form of POSIX path of source_file
            set wholePath to fPath & source_file

            --Creates text file
            try
                do shell script "touch " & pPath & "results.txt"
            end try

            --Check to see if there is a file extension
            if itemExtension is "" then
                -- "" means there is no file-extension present.
                set file_extension to ""
            else
                --yup, we are currently processing a file that has a file-extension
                --we have to re-add the original file-extension after changing the name of the file!
                set file_extension to "." & itemExtension
            end if

            --Gets the height and width of each file
            set dimensions to paragraphs of (do shell script "sips -g pixelHeight -g pixelWidth " & quoted form of wholePath & " | grep pixel | cut -d':' -f 2 | cut -d ' ' -f 2")
            set h to (item 1 of dimensions) --/ dpi_to_dpmm -- works out pixel height as mm
            set w to (item 2 of dimensions) --/ dpi_to_dpmm -- works out pixel width as mm


            if w is greater than or equal to 548 then
                --Col1
                set the name of this_file to new_FirstnameCol1 & universalCounter & new_LastNameCol1 & col1 & file_extension as string
                set txtName to new_FirstnameCol1 & universalCounter & new_LastNameCol1 & col1 as string


            else if w is greater than or equal to 288 then
                --Col2
                set col2 to col2 + 1
                set the name of this_file to new_FirstnameCol2 & universalCounter & new_LastNameCol2 & col2 & file_extension as string
                set txtName to new_FirstnameCol2 & universalCounter & new_LastNameCol2 & col2 as string
                if col2 > 1 then
                    set col2 to 0

                else
                    set columnCounter to columnCounter + 1
                end if
            else if w is greater than or equal to 101 then
                --Column 3
                set col3 to col3 + 1
                set the name of this_file to new_FirstnameCol3 & universalCounter & new_LastNameCol3 & col3 & file_extension as string
                set txtName to new_FirstnameCol3 & universalCounter & new_LastNameCol3 & col3 as string
                if col3 > 2 then
                    set col3 to 0

                else
                    set columnCounter to columnCounter + 1
                end if
            else if w is greater than or equal to 1 then
                --Oops
                set the name of this_file to new_FirstnameCol1 & new_LastNameCol1 & "_oops" & i & file_extension as string
                set txtName to new_FirstnameCol1 & new_LastNameCol1 & "_oops" & i as string

                set oopsCounter to oopsCounter + 1
            else
                --Oops
                set the name of this_file to new_FirstnameCol1 & new_LastNameCol1 & "_oops" & i & file_extension as string
                set txtName to new_FirstnameCol1 & new_LastNameCol1 & "_oops" & i as string

                set oopsCounter to oopsCounter + 1
            end if
            do shell script "echo '" & txtName & " " & w & " x " & h & "' >> " & pPath & "results.txt"

        end repeat
        --End Normal Email

        --** remove this section if adding more options
    else
        display alert "Something Went Wrong"
        --** remove this section if adding more options
        end if
end tell
हमारी साइट का प्रयोग करके, आप स्वीकार करते हैं कि आपने हमारी Cookie Policy और निजता नीति को पढ़ और समझा लिया है।
Licensed under cc by-sa 3.0 with attribution required.