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

  • SEARCH
  • Home
  • 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 9089913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:15:16+00:00 2026-06-16T22:15:16+00:00

I am currently in the process of building an AppleScript application. (Note that this

  • 0

I am currently in the process of building an AppleScript application. (Note that this is a plain AppleScript “application” created by using AppleScript Editor to create an AppleScript and then saving that script as an application). For this app, I need to know the filepaths of the recently opened files for the current user. I’ve tried many different methods so far, but none seem to be giving me the information that I need.

I’ve tried the following:

  • I’ve tried the com.apple.recentitems.plist file, however the filepath information contained inside this file seems to be in Hex format, which when converted into ASCII is full of a lot of mumbo-jumbo, and the format of the mumbo-jumbo seems to change for different files and on different computers.
  • I’ve tried using the unix find command to filter files opened in the past day, however here I can only choose between recently modified and recently accessed, not recently opened. Recently modified files won’t include opened files which aren’t modified (like an image that is opened but not edited), and recently accessed files seems to show all files which have been visible in Finder in thumbnail view, even if they haven’t been opened by the user.
  • I’ve tried venturing into Objective-C and the LaunchServices/LSSharedFileList.h file for getting kLSSharedFileListRecentDocumentItems (similar to this answer), however I’ve never used Objective-C before so I’ve not been able to get anything to work properly with this.

Any help that anyone could provide to help me to get a list of the recently opened files for the current user would be very much appreciated. Furthermore, any help with being able to write the list of recently changed files to a text file would be great.

  • 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-06-16T22:15:17+00:00Added an answer on June 16, 2026 at 10:15 pm

    Your solution probably works, but perhaps what I came up with might be more workable.

    Of the proposed 3 options you came up with, indeed the LSSharedFile* commands are the best solution.

    With the advent of AppleScript script bundles (.scptd) and scripts that can be saved as application bundles (.app), you can quite easily include custom executables inside the bundle. As a result, you can make use of these executables to accomplish what you need to do if you couldn’t accomplish it with AppleScript alone or the default BSD subsystem tools.

    So, in Xcode I created a new “Foundation Tool” project which used the following code:

    int main(int argc, const char * argv[]) {
        @autoreleasepool {
            UInt32 resolveFlags = 0;
            NSArray *arguments = [[NSProcessInfo processInfo] arguments];
            if (arguments.count > 1) {
                NSArray *revisedArguments = [arguments
                            subarrayWithRange:NSMakeRange(1, arguments.count - 1)];
                for (NSString *arg in revisedArguments) {
                    if ([arg isEqualToString:@"--noUserInteraction"]) {
                        resolveFlags |= kLSSharedFileListNoUserInteraction;
                    } else if ([arg isEqualToString:@"--doNotMountVolumes"]) {
                        resolveFlags |= kLSSharedFileListDoNotMountVolumes;
                    }
                }
            }
            LSSharedFileListRef sharedFileListRef = LSSharedFileListCreate(NULL,
                                  kLSSharedFileListRecentDocumentItems, NULL);
            NSArray *sharedFileListItemRefs =
               (NSArray *)LSSharedFileListCopySnapshot(sharedFileListRef, NULL);
            for (id itemRef in sharedFileListItemRefs) {
                NSURL *resolvedURL = nil;
                LSSharedFileListItemResolve((LSSharedFileListItemRef)itemRef,
                     resolveFlags, (CFURLRef *)&resolvedURL, NULL);
                if (resolvedURL) {
                    printf("%s\n", resolvedURL.path.fileSystemRepresentation);
                    [resolvedURL release];
                }
            }
            if (sharedFileListRef) CFRelease(sharedFileListRef);
            [sharedFileListItemRefs release];
            return EXIT_SUCCESS;
        }
    }
    

    While this code is similar to yours, instead of having to write the results to an intermediary file, it simply prints the file paths to standard out. This should allow dramatically-simplified coding on the AppleScript end of things. The result of building this Xcode project is a single “Unix Executable File” named recentItemsFinagler instead of an application bundle.

    To make use of this built executable in an AppleScript, you first need to make sure the script is saved as a Script Bundle or Application and then the Bundle Contents toolbar item should be enabled like in the image below:

    enter image description here

    Clicking that toolbar item shows the drawer which shows the contents of the script bundle or application bundle. To add your custom executable, just drag and drop it from the Finder like in the image below:

    enter image description here

    This will copy it into the script bundle like shown:

    enter image description here

    To locate this executable at runtime, you can use the path to resource AppleScript command which is part of the StandardAdditions.osax. (Note that depending on how you try to make use of the path to resource command in your script, you may encounter “Resource not found” errors when you run the script from within AppleScript Editor as opposed to running it by double-clicking on it in the Finder. If you encounter this type of an error, first make sure you’ve saved all of your changes to the script, then quit out of AppleScript Editor, then launch the script application by double-clicking on it in the Finder, after the script finishes running, re-open AppleScript Editor, then re-open the script application, then try running from within AppleScript Editor and see if it works).

    So, to make use of this recentItemsFinagler in your AppleScript, you could do something like the following:

    property recentItemsFinagler : missing value
    
    if (recentItemsFinagler = missing value) then
        set recentItemsFinagler to (path to resource "recentItemsFinagler")
    end if
    
    set toolPath to quoted form of POSIX path of recentItemsFinagler
    
    set recentItemsString to (do shell script toolPath & " --noUserInteraction --doNotMountVolumes")
    
    set recentItemsPaths to paragraphs of recentItemsString
    

    I’ll go through this AppleScript line by line to explain what it’s doing. We first create a global property recentItemsFinagler, and set its initial value to missing value. (missing value is the AppleScript equivalent to Objective-C’s nil).

    In case you’re not aware of it, global properties in AppleScript are like global variables in other languages with one important addition: when you run the script and assign a value to the property, that value is actually saved in the script file itself, and will persist to the next time you run the script.

    The script first checks to see if recentItemsFinagler is equal to missing value, and if it is, sets it to the result of (path to resource "recentItemsFinagler"), which is an AppleScript alias reference. This is similar to an alias in the Finder in that it is able to successfully track changes like renames, and moving from one folder to another. If I had instead stored it as a simple string, and then moved this AppleScript application bundle from my Documents folder to my Desktop, the path would no longer be valid, and the property would have to be updated each time the script was run.

    Anyway, we then set recentItemsString to the result of the AppleScript do shell script recentItemsFinagler tool, which is a string. To turn this into an AppleScript list of strings which represent paths, you use the paragraphs of command.

    So by including the executable inside the script or AppleScript application’s bundle, you can get the desired result in less than 10 lines of code.

    Sample project: RecentItemsFinagler.zip

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

Sidebar

Related Questions

I am building an application and currently am in the process of add backgrounds
I am currently in the process of writing an application in Java that creates
I am currently in the process of building a native Google Reader iPhone application
Currently I am building an application that launches crtmpd (a rtmp server written in
I'm currently in the process of building a repository for a project that will
I'm currently in the process of building an embedded system, using an ARM Cortex
My team is currently in the process of building an ASP.NET MVC application, and
I'm currently in the process of building a game using the MVC pattern. I
I'm currently building a Java application using two threads : The first thread is
I'm in the process of building an app that currently contains a LOT of

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.