Skip to main content
4 of 4
added 613 characters in body
wch1zpink
  • 7.7k
  • 17
  • 34

Assuming that all of the picture files are located in the Pictures folder, this following AppleScript code should work.

Paste this following code into a new Script Editor.app document. You can run the code directly from that document or you can save the code as an application and run the application like you would with any other app.

activate
set picturesFolder to choose folder with prompt ¬
    "Choose The Folder Containing Your Pictures" with invisibles

activate
set categoriesFolder to choose folder with prompt ¬
    "Choose The Categories Folder" with invisibles

tell application "Finder"
    activate
    set pictureFiles to files of picturesFolder as alias list
    repeat with i from 1 to count of pictureFiles
        set foldersRef to (a reference to folders of categoriesFolder)
        set foldersRefItems to name of (contents of foldersRef)
        set thisItem to item i of pictureFiles
        set fileName to (text items 1 thru -5) of (name of thisItem as text) as string
        if fileName is not in foldersRefItems then
            ---- This Will Create Aliases To The Original Files ----
            ---- Much Quicker And Space Efficient Than Duplicating The Files ----
            make new alias file at (make new folder at categoriesFolder ¬
                with properties {name:fileName}) ¬
                to thisItem with properties {name:fileName}
            
            ---- Un-Comment The Next 2 Lines If You Prefer To Duplicate The Files ----
            -- duplicate thisItem to (make new folder at categoriesFolder ¬
            -- with properties {name:fileName})
        else
            try
                ---- Un-Comment The Next Line If You Prefer To Duplicate The Files ----
                -- Duplicate Thisitem To Folder Filename Of Categoriesfolder --
                
                make new alias file at categoriesFolder ¬
                    to thisItem with properties {name:fileName}
            end try
        end if
    end repeat
end tell
wch1zpink
  • 7.7k
  • 17
  • 34