Folder Action Applescript

I’m struggling to create a Folder Action to Open Number Application to run a script and save

Sounds easy but not having done this before its all very confusing

I have a AppleScript which I use currently but this means manually opening each CSV file, selecting the Table then running the Scrip and then Saving the File

I’d love to be able to do this with a Folder action, below is the script I run manually, if one of you clever people can help it would be appreciated.

CURRENT SCRIPT

tell application “Numbers”
activate

try
    if not (exists document 1) then error number 1000
    tell document 1
        try
            tell active sheet
                set the selectedTable to ¬
                    (the first table whose class of selection range is range)
            end tell
        on error
            error number 1001
        end try
        tell selectedTable
            -- currently, use of headers and footers cannot be determined by a script.
            -- make the following assumptions:
            set usesHeaders to true -- assume 1 row and 1 column
            set usesFooters to false -- assume 1 row
            -- add a new column
            add column after last column
            set the summationColumn to the last column
            -- set the formula of each cell of the summation column
            tell summationColumn
                if usesHeaders is true then
                    set startIndex to 2
                else
                    set startIndex to 1
                end if
                repeat with i from startIndex to the count of cells
                    -- get the row of the cell
                    set thisRow to the row of cell i
                    -- determine range coordinates
                    set the rangeStart to the name of cell startIndex of thisRow
                    set the rangeEnd to the name of cell -2 of thisRow
                    -- create formula using SUM function
                    set the summationFormula to ¬
                        ("=CEILING(" & rangeEnd & "," & 16 & ")") as string
                    -- set the formula to the cell
                    set the value of cell i to summationFormula
                end repeat
            end tell
        end tell
        tell selectedTable
            -- currently, use of headers and footers cannot be determined by a script.
            -- make the following assumptions:
            set usesHeaders to true -- assume 1 row and 1 column
            set usesFooters to false -- assume 1 row
            -- add a new column
            add column after last column
            set the summationColumn to the last column
            -- set the formula of each cell of the summation column
            tell summationColumn
                if usesHeaders is true then
                    set startIndex to 2
                else
                    set startIndex to 1
                end if
                repeat with i from startIndex to the count of cells
                    -- get the row of the cell
                    set thisRow to the row of cell i
                    -- determine range coordinates
                    set the rangeStart to the name of cell startIndex of thisRow
                    set the rangeEnd to the name of cell -2 of thisRow
                    -- create formula using SUM function
                    set the summationFormula to ¬
                        ("=SUM(" & rangeEnd & "/" & 16 & ")") as string
                    -- set the formula to the cell
                    set the value of cell i to summationFormula
                end repeat
            end tell
        end tell
    end tell
    tell selectedTable
        set Qty2 to "Qty2"
        set Pr1 to "Print"
        set the value of cell 1 of column "J" to Qty2
        set the value of cell 1 of column "K" to Pr1
    end tell
    
on error errorMessage number errorNumber
    if errorNumber is 1000 then
        set alertString to "MISSING RESOURCE"
        set errorMessage to ¬
            "Please create or open a document before running this script."
    else if errorNumber is 1001 then
        set alertString to "SELECTION ERROR"
        set errorMessage to ¬
            "Please select a table before running this script."
    else
        set alertString to "EXECUTION ERROR"
    end if
    if errorNumber is not -128 then
        display alert alertString message errorMessage buttons {"Cancel"}
    end if
    error number -128
end try

end tell

Tried all variants but I’m unable to to selct the Table within Nimbers to run the Script, not even got as far as saving the files

New contributor

Mark Casey is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật