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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:53:28+00:00 2026-05-16T00:53:28+00:00

I was wondering if there was a way in Automator to use Applescript code

  • 0

I was wondering if there was a way in Automator to use Applescript code to get the extension of a file, and if it equals a specific extension (e.g. .pdf or .rtf) move to a specific folder for that extension (e.g if (extension == pdf) { move to folder "~/PDF Files" } else if (extension == rtf) { move to folder "~/Rich Text Files" })

  • 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-16T00:53:29+00:00Added an answer on May 16, 2026 at 12:53 am

    Here’s an applescript. Since your request was simple I just wrote it for you. Note how I get the file extension with the subroutine “getNameAndExtension(F)”. Normally you can get the file extension from the Finder (called name extension) but I’ve found that the Finder is not always reliable so I always use that subroutine. That subroutine has always been reliable.

    set homeFolder to path to home folder as text
    set rtfFolderName to "Rich Text Files"
    set pdfFolderName to "PDF Files"
    
    -- choose the files
    set theFiles to choose file with prompt "Choose RTF or PDF files to move into your home folder" with multiple selections allowed
    
    -- make sure the folders exist
    tell application "Finder"
        if not (exists folder (homeFolder & rtfFolderName)) then
            make new folder at folder homeFolder with properties {name:rtfFolderName}
        end if
        if not (exists folder (homeFolder & pdfFolderName)) then
            make new folder at folder homeFolder with properties {name:pdfFolderName}
        end if
    end tell
    
    -- move the files
    repeat with aFile in theFiles
        set fileExtension to item 2 of getNameAndExtension(aFile)
        if fileExtension is "rtf" then
            tell application "Finder"
                move aFile to folder (homeFolder & rtfFolderName)
            end tell
        else if fileExtension is "pdf" then
            tell application "Finder"
                move aFile to folder (homeFolder & pdfFolderName)
            end tell
        end if
    end repeat
    
    
    
    (*=============== SUBROUTINES ===============*)
    on getNameAndExtension(F)
        set F to F as Unicode text
        set {name:Nm, name extension:Ex} to info for file F without size
        if Ex is missing value then set Ex to ""
        if Ex is not "" then
            set Nm to text 1 thru ((count Nm) - (count Ex) - 1) of Nm
        end if
        return {Nm, Ex}
    end getNameAndExtension
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.