Quicker way to copy files to a set of different folders for classification purposes
For each of these pictures, I'd like to send it to a sub-folder of the folder "categories". For instance, if there is a picture of a boat, I want to copy (not move) this picture to "categories/boat".
I don't recommend this approach.
This just creates multiple, on multiple, on multiple duplicates of the same file. Just doing a little bit of math, if each photo applied to just 3 categories, storing them in your method, the number of photos you would have goes up to 45,000.
What you need is Photo (or image) management software which is just a very specific content management system. The way this software works is by embedding meta data into the photo (or in Lightroom's case, they create a library of meta data that gets associated with the file, never touching the file directly). So, if you had a photo that fell into 5 different categories, you wouldn't have 5 identical copies of the photo, you'd have one with 5 different ways of finding it. Several of these applications have "dupe finders" which is a feature designed to solve the problem of the same file in multiple places!
Here's a list of some popular Photo Management products. I'm very familiar with Bridge and Lightroom as well as ACDSee from the 1990s and I recommend them wholeheartedly. I have had some brief experience with the Open Source products (FOSS) and they look to be very promising but depending on your needs, YMMV.
- Apple Photos (Included with macOS)
- Adobe Lightroom
- Adobe Bridge (Free with purchase of Photoshop or Illustrator)
- Cyberlink PhotoDirector
- Magix Photo Manager
- ACDSee Photo Studio
- Darktable (FOSS)
- LightZone (FOSS)
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