Skip to main content
added 613 characters in body
Source Link
wch1zpink
  • 7.7k
  • 17
  • 34
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
            duplicate---- thisItemThis toWill 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}) ¬
        else        to thisItem with properties {name:fileName}
            try
            ---- 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})
 of       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
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
            duplicate thisItem to (make new folder at categoriesFolder ¬
                with properties {name:fileName})
        else
            try
                duplicate thisItem to folder fileName of categoriesFolder
            end try
        end if
    end repeat
end tell
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
added 29 characters in body
Source Link
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
            duplicate thisItem to (make new folder at categoriesFolder ¬
                with properties {name:fileName})
        else
            try
                duplicate thisItem to folder fileName of categoriesFolder
            end try
        end if
    end repeat
end tell

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.

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

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
            duplicate thisItem to (make new folder at categoriesFolder ¬
                with properties {name:fileName})
        else
            duplicate thisItem to folder fileName of categoriesFolder
        end if
    end repeat
end tell

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
            duplicate thisItem to (make new folder at categoriesFolder ¬
                with properties {name:fileName})
        else
            try
                duplicate thisItem to folder fileName of categoriesFolder
            end try
        end if
    end repeat
end tell
deleted 82 characters in body
Source Link
wch1zpink
  • 7.7k
  • 17
  • 34

Let’s assume that your Pictures folder is located on your desktop and the Categories folder is located inside of the pictures folder. AssumingAssuming 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.

propertyset picturesFolder : (path to desktopchoose folder aswith text)prompt &¬
 "Pictures" as alias
property categoriesFolder"Choose :The (pathFolder Containing Your Pictures" with invisibles

set categoriesFolder to desktopchoose folder aswith text)prompt &¬
 "Pictures:Categories" as alias "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
            duplicate thisItem to (make new folder at categoriesFolder ¬
                with properties {name:fileName})
        else
            duplicate thisItem to folder fileName of categoriesFolder
        end if
    end repeat
end tell

Let’s assume that your Pictures folder is located on your desktop and the Categories folder is located inside of the pictures folder. Assuming that all of the picture files are located in the Pictures folder, this following AppleScript code should work.

property picturesFolder : (path to desktop folder as text) & "Pictures" as alias
property categoriesFolder : (path to desktop folder as text) & "Pictures:Categories" as alias

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
            duplicate thisItem to (make new folder at categoriesFolder ¬
                with properties {name:fileName})
        else
            duplicate thisItem to folder fileName of categoriesFolder
        end if
    end repeat
end tell

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.

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

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
            duplicate thisItem to (make new folder at categoriesFolder ¬
                with properties {name:fileName})
        else
            duplicate thisItem to folder fileName of categoriesFolder
        end if
    end repeat
end tell
Source Link
wch1zpink
  • 7.7k
  • 17
  • 34
Loading