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 8559463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:03:10+00:00 2026-06-11T16:03:10+00:00

I am successfully opening 1 random file, like this: tell application Finder open some

  • 0

I am successfully opening 1 random file, like this:

tell application "Finder"
   open some file of folder "HD:random"
end tell

I would like to open 3 random files in the folder. 3 different ones. If I run the applescript 3 times I will get the same ones sometimes.

Thanks!

  • 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-11T16:03:12+00:00Added an answer on June 11, 2026 at 4:03 pm

    Here’s 1 way using “some file”…

    set theNumber to 3
    set theFolder to choose folder
    
    set theFiles to {}
    repeat
        tell application "Finder" to set aFile to (some file of theFolder) as text
        if aFile is not in theFiles then
            set end of theFiles to aFile
            tell application "Finder" to open file aFile
        end if
        if (count of theFiles) is equal to theNumber then exit repeat
    end repeat
    

    Here’s another way using random numbers…

    set theNumber to 3
    set theFolder to choose folder
    
    tell application "Finder" to set theFiles to files of theFolder
    set fileCount to count of theFiles
    if fileCount is less than theNumber then error "I couldn't find " & (theNumber as text) & " files in the chosen folder."
    
    set randomNumbers to {}
    repeat
        set aNum to random number from 1 to fileCount
        if aNum is not in randomNumbers then
            set end of randomNumbers to aNum
            tell application "Finder" to open (item aNum of theFiles)
        end if
        if (count of randomNumbers) is equal to theNumber then exit repeat
    end repeat
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some files in a folder on the harddrive, like C:\ExtraContent\ that has
When opening the ObjectieGitFramework.xcodeproj file I can now build the iOS scheme successfully. A
After successfully opening Pop3Folder , and retrieving messages from it, I then sometimes get
I successfully installed the latest QuantumGrid from DevExpress, but I've never worked with this
This is sufficiently important to me that I'm opening the question up to a
Hello every one this is extension to my previous question.Here is the link File
I am currently writing a new line to a CSV-file each time I successfully/unsuccessfully
This all goes back to some of my original questions of trying to index
I've successfully created some test pages using the Fancybox library. However, when I try
I'm writing an automated test to determine whether or not rtf files are successfully

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.