xtrmn8ngangl

Q: Logging Hours Worked

Hello,

 

I'm new to this, but I would like to learn to write an applescript that would carry out a very specific work flow.

 

Ideally this is what would happen.

 

run the script

dialog opens asking me to "Check In" or "Check Out"

 

If I choose "Check In"

fill a specified "Numbers" table cell with the current date and time.

(each time the script runs filling in the next row of the spread sheet).

&

Launch my application to begin work (Avid Media Composer).

 

If I choose "Check Out"

fill a specified "Numbers" table cell with the current date and time.

(the next column from the previous "Check In").

&

Create a copy(zip archive) of my Avid project folder.

 

If anyone knows of a tutorial or something that I could study that would be great.

Just looking for a lead...

 

I can launch my app and create the archive in automator, but was hoping to log my hours somehow as well.

 

thanks for the help,

Aaron

 


MacBook Pro, Mac OS X (10.6.6), 4gb ram

Posted on Nov 17, 2013 5:41 PM

Close

Q: Logging Hours Worked

  • All replies
  • Helpful answers

Previous Page 2
  • by Pierre L.,

    Pierre L. Pierre L. Nov 18, 2013 5:21 PM in response to xtrmn8ngangl
    Level 5 (4,484 points)
    Nov 18, 2013 5:21 PM in response to xtrmn8ngangl

    Change the last part of the script as follows:

     

    if checkIn then

        tell application "TextEdit" to activate -- launch the application to begin work

    else

        tell application "TextEdit" to quit -- quit the application

     

        -- Create a copy (zip archive) of your Avid project folder

        tell application "Finder"

            activate

            select theFolder

            tell application "System Events" to tell process "Finder" to click (menu item 1 of menu 1 of menu bar item "File" of menu bar 1 whose name begins with "Compress")

        end tell

     

        -- Move the archive to the folder of your choice:

        set theFolderPath to POSIX path of theFolder

        set theArchive to POSIX file (text 1 through -2 of theFolderPath & ".zip")

        tell application "Finder"

            repeat until theArchive exists

            end repeat

            move theArchive to folder theDestinationFolder with replacing

        end tell

    end if

  • by xtrmn8ngangl,

    xtrmn8ngangl xtrmn8ngangl Nov 20, 2013 4:11 PM in response to Pierre L.
    Level 1 (0 points)
    Nov 20, 2013 4:11 PM in response to Pierre L.

    Hello,

     

    So this is the closet I have been able to get to what i need.

     

    Is it possible to give this script a look.

    It runs fine, but only about 50% of the time.

    Sometimes it stops before inputting the data into my spread sheet.

     

    In those cases it also does not launch or quit the application.

     

    Let me know if you can see what is causing this...

     

    set theFolder to POSIX file "/Users/Shared/AvidMediaComposer/Shared Avid Projects/Reciprocity" as alias

    set theSpreadSheet to POSIX file "/Users/Aaron/Desktop/Reciprocity/Reciprocity Work Log.numbers" as alias

    set theDestinationFolder to POSIX file "/Users/Aaron/Dropbox/Reciprocity Backup" as alias

     

     

    -- Dialog asking to "Check In" or "Check Out"

    set theResult to display dialog "What will it be?" default answer "Project Name or Notes" buttons {"Cancel", "Check In", "Check Out"} cancel button 1 with icon 1 with title "Some title"

     

    set theAnswer to text returned of theResult

    set theButton to button returned of theResult

     

     

    tell application "Numbers"

      -- open the spreadsheet (a Numbers document):

      launch

     

              if not (exists (document 1 whose path is theSpreadSheet)) then

      open theSpreadSheet

              end if

     

      -- fill in the appropriate cell:

              tell front document

                        tell table 1 of sheet 1

                                  set theCell to cell 1 of column "B" whose (name is not "B1") and (value = 0)

                                  set theProject to cell 1 of column "A" whose (name is not "A1") and (value = 0)

                                  set theNotes to cell 1 of column "E" whose (name is not "E1") and (value = 0)

     

                                  if theButton is "Check In" then

                                            set checkIn to true

                                            set value of theCell to (current date) as text -- check-in date & time

                                            set value of theProject to theAnswer -- Dialog box

     

                                            tell application "Numbers" to quit

                                  else

                                            set checkIn to false

                                            set theRow to address of row of theCell

                                            set theCell to cell (theRow - 1) of column "C"

                                            set value of theCell to (current date) as text -- check-out date & time

                                            set value of theNotes to theAnswer -- Dialog box

      add row below theCell

     

                                            tell application "Numbers" to quit

                                  end if

                        end tell

              end tell

      save

    end tell

     

     

    if checkIn then

              tell application "TextEdit" to activate -- launch the application to begin work

    else

     

              tell application "TextEdit" to quit -- quit the application

     

      -- Create a copy (zip archive) of your Avid project folder in the folder of your choice.

              tell application "ReciprocityCheckOut"

      activate

              end tell

    end if

     

    PS- i made a automator application to create a zip archive and i launch that from the applescript...

     

    thanks for the insight,

    Aaron

     

  • by Pierre L.,

    Pierre L. Pierre L. Nov 20, 2013 6:50 PM in response to xtrmn8ngangl
    Level 5 (4,484 points)
    Nov 20, 2013 6:50 PM in response to xtrmn8ngangl

    Hi Aaron,

     

    Unfortunately, I know nearly nothing about Automator. So I cannot help you with the last part of your script. What I've done, however (now that I've got a better idea of what you want to do) was to revise and improve my previous script. The new version of the script seems to work flawlessly under OS X 10.9, even with big archives. Here it is:

     

     

    set theFolder to POSIX file "/Users/Shared/AvidMediaComposer/Shared Avid Projects/Reciprocity" as alias

    set theSpreadSheet to POSIX file "/Users/Aaron/Desktop/Reciprocity/Reciprocity Work Log.numbers" as alias

    set theDestinationFolder to POSIX file "/Users/Aaron/Dropbox/Reciprocity Backup" as alias

     

    -- Dialog asking to "Check In" or "Check Out":

    display dialog "What will it be?" default answer "Project Name or Notes" buttons {"Cancel", "Check In", "Check Out"} cancel button 1 with icon 1 with title "Some title"

    set {theAnswer, theButton} to {text returned, button returned} of result

     

    tell application "Numbers ’09"

        if not (exists (document 1 whose path is theSpreadSheet)) then

            open theSpreadSheet

            repeat until (document 1 whose path is theSpreadSheet) exists

            end repeat

        end if

     

        -- fill in the appropriate cell:

        tell table 1 of sheet 1 of front document

            if theButton is "Check In" then

                set checkIn to true

                set theProject to cell 1 of column "A" whose (value = 0) and (name is not "A1")

                set theCurrentRow to address of row of theProject as text

                set value of theProject to theAnswer

                set value of cell ("B" & theCurrentRow) to (current date) as text

            else

                set checkIn to false

                set theProject to last cell of column "A" whose (value is not 0)

                set theCurrentRow to address of row of theProject

                set value of cell ("C" & theCurrentRow) to (current date) as text

                set value of cell ("E" & theCurrentRow) to theAnswer

                add row below theProject

            end if

        end tell

     

        delay 2 -- optional, just to see the values entered in the cells

        quit -- or "save" if you don't want to quit right now

    end tell

     

     

    if checkIn then

        tell application "TextEdit" to activate -- launch the application to begin work

    else

        tell application "TextEdit" to quit -- quit the application

     

        -- Create a zip archive of your Reciprocity folder

        -- and move it into your Reciprocity Backup folder:

     

        set theFolderPath to POSIX path of theFolder

        set theArchive to POSIX file (text 1 through -2 of theFolderPath & ".zip")

     

        tell application "Finder"

            activate

            select theFolder

        end tell

     

        tell application "System Events" to tell process "Finder"

            tell menu 1 of menu bar item "File" of menu bar 1

                click (menu item 1 whose name begins with "Compress")

            end tell

        end tell

     

        tell application "Finder"

            repeat until exists theArchive

            end repeat

            move theArchive to folder theDestinationFolder with replacing

        end tell

    end if


     

    Hope it can help.

Previous Page 2