0

I am trying to get data out of a table in Numbers. I have an index number, I need to get the name associated with it in applescript. (Eventually I need to set names of files with one of columns of this number sheet)

here is what I got:

tell application "iTunes"
    repeat with theTrack in selection
        set theFile to location of theTrack
        tell application "Finder" to set theName to name of theFile
        set surahNameAsString to characters 1 thru 3 of theName as text
        --set album of theTrack to surahName
        set surahNumber to surahNameAsString as integer
        log ("here")

        set aName to my getAName(surahNumber)

        --set the year of theTrack to 1985

    end repeat
end tell

on getAName(surahNumber)
    tell application "Numbers"
        activate
        set t to front document's active sheet's first table's cell whose value is surahNumber
        --set t to front document's active sheet's first table's first column
        repeat with c in t
            set theValue to c's value
        end repeat
    end tell
    return theValue
end getAName
  • 2
    You need to also show an example of the numbers doc. And explain what your script is failing to do rather than us trying to run it on a doc that is nothing like yours.... – markhunte Jan 1 '15 at 8:39
1

this is how I solved it:

tell application "iTunes"

    repeat with theTrack in selection

        set theFile to location of theTrack
        tell application "Finder" to set theName to name of theFile

        set ayahInSurahCount to 0

        --set ayah information from the name of the track

        set surahNumAsString to characters 1 thru 3 of theName as text
        set surahNumber to surahNumAsString as integer

        set ayahNumberAsString to characters 4 thru 6 of theName as text
        set ayahNumber to ayahNumberAsString as integer
        -- finished

        set track number of theTrack to ayahNumber
        set genre of theTrack to "Genre"
        --getting information from the number sheet
        set aName to my getAName(surahNumber)
        --set englishName to my getEnglishName(surahNumber)
        -- finished
        set the album of theTrack to surahNumAsString & "-" & aName
        set artist of theTrack to "Abdul Basit"
        set shufflable of theTrack to false
        --set description of theTrack to englishName
        set name of theTrack to ayahNumberAsString & " - "

    end repeat
end tell

on getAName(surahNumber)
    tell application "Numbers"
        activate
        tell document 1
            tell sheet 1
                tell table 1
                    set ret to value of cell 1 of row surahNumber
                    --set value of cell 5 of row 1 to "Salam"
                end tell
            end tell
        end tell
    end tell
    return ret
end getArabicName

on getEnglishName(surahNumber)
    tell application "Numbers"
        activate
        tell document 1
            tell sheet 1
                tell table 1
                    set ret to value of cell 3 of row surahNumber
                end tell
            end tell
        end tell
    end tell
    return ret
end getEnglishName
  • 2
    Solved what?. We do not know what your original script was failing to do? – markhunte Jan 1 '15 at 17:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .