Finding the file path for an open document in Audacity

However, if you open only one file at a time, then the topmost item of the “Recent” menu always corresponds to the open file.

You can get the file path with this:

tell application "System Events"
  tell process "Audacity"
    tell menu bar 1
      tell menu "File"
        tell menu item "Open Recent"
          tell menu "Open Recent"
            set mostRecentFile to name of menu item 1
          end tell
        end tell
      end tell
    end tell
  end tell
end tell

Then you can further process the mostRecentFile variable with KM or AppleScript…

(In this form the script works only if a file window is open.)

2 Likes