Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7598465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:24:50+00:00 2026-05-30T22:24:50+00:00

I have an AppleScript script that I use to display iTunes track information on

  • 0

I have an AppleScript script that I use to display iTunes track information on my desktop with GeekTool. I use on runargv to pass different parameters to the script so I can show different parts of the track information without duplicating the script (for example, I can get just the title by running osascript itunes.scpt title and I can get the artist/album by running osascript itunes.scpt album).

However, every time I run the script with an argument, the actual file modification date is changed—it seems that the script is writing something to itself or making some sort of modification.

This isn’t ordinarily a problem, except in OS X 10.7, where Lion introduced file locking for files that haven’t been modified in more than 2 weeks. Once my iTunes script is locked by the OS, it can’t make any more of these invisible self updates when it runs, and my system log gets riddled with errors like this:

osascript: couldn't save changes to script /path/to/script: error -54

I can fix this temporarily by making some modification to the script manually (adding empty lines, for example), but two weeks later it all breaks down again because Lion locks it.

I could theoretically disable file locking systemwide to fix this, but I’d rather not—I like it for other things.

So, how can you use on run argv to pass arguments to AppleScript files without changing the modification date of that script?

Here’s a minimal working example. If you run this from the command line (oscascript test.scpt blah), the script’s modification date will change.

--test.scpt
on run argv
    tell application "iTunes"
        if player state is playing then
            set trck to current track
            set title_text to (get name of trck)
            return title_text & " " & item 1 of argv
        end if
    end tell
end run
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T22:24:52+00:00Added an answer on May 30, 2026 at 10:24 pm

    In addition to properties that are defined in a regular AppleScript (not the Xcode variety), all global variables are persistent and are saved with a script (at least until it is recompiled). This includes items defined in the run handler (either explicit or implied), for example:

    on run
        try
            display dialog someVariable -- will error the first time
        on error -- set global
            beep
            set someVariable to time string of (current date)
        end try
    end run
    

    You might try moving your code to a handler so that global variables are not set or changed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Applescript I use in conjunction with Alfred that plays or pauses
So I have this program that I really like, and it doesn't support Applescript.
I have a shell script that outputs filenames (one per line). I want to
I have a bunch of AppleScript scripts in a directory that I want to
I have created a script with AppleScript to extract email body according to some
I have this applescript that takes the selected item and zips that file/folder and
In Applescript, I have the following: do shell script /Applications/Vidalia.app/Contents/MacOS/Vidalia do shell script /Applications/Firefox_3.6/Firefox.app/Contents/MacOS/firefox-bin
I'm just starting with applescript in xcode and currently have an app that asks
I have some AppleScript code that I'm executing with osascript . This is part
I have an AppleScript program which creates XML tags and elements within an Adobe

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.