Is there some script that can automate the dividing of a folder of images into Sub-folders? I have a bunch of folder of 1000 or so images that I want to group into sub-folders of 25 images each. So far I’ve just been manually selecting 25 pictures and then grouping them, and then selecting the next set of 25 and grouping them into a new sub-group. Is there some way to use AppleScript or Automator so that this can be done automatically?
Yes, so my image files are all numbered, say from 0 to 932, and I want to put 0-25 in folder 1, 26-50 in folder 2, 51-76 in folder 3 and so on. Also I’m not sure if it matters, but say in a folder of 90 images, is there some way to go 25, 25, 25, and 15 in the last folder?
Try this. For safety, the script duplicates documents and does not delete the original. You need to do that manually. You are prompted for the base name that is used to create each new group. You are also prompted for how many items you want in each group (e.g. 25). The target groups are created in the database root. One enhancement would be to use the “display group selector” option to chose the target group.
Use at your own risk; no guarantees - including against losing your data.
Caveat: if you’re splitting 1,000 images this script will take a very long time to run during which DTPO will be hung up and not responsive.
-- Split Records into Groups
-- Use at your own risk: data loss is your risk
-- Made by korm 20100429
-- Could be enhanced by using "display group selector"
-- This is experimental. Statements can be consolidated by anyone who wants to clean up this script
tell application id "com.devon-technologies.thinkpro2"
try
set theDatabase to current database
set theGroup to current group
set GroupBaseName to text returned of (display dialog "What is the base name for groups?" default answer "<<enter default base name>>")
set GroupCount to text returned of (display dialog "How many records in a group?" default answer "<<enter number of records in a group>>")
set theseItems to selection
if theseItems is {} then error "Please make a selection"
set theItemCounter to 1
set theGroupCounter to 1
set theGroupCounter_str to theGroupCounter as string
set GroupName to (GroupBaseName & " (Group: " & theGroupCounter_str & ")")
set CurrentTarget to create location GroupName in theDatabase
repeat with thisItem in theseItems
if theItemCounter < (GroupCount + 1) then
duplicate record thisItem to CurrentTarget
set theItemCounter to theItemCounter + 1
end if
if theItemCounter = (GroupCount + 1) then
set theGroupCounter to theGroupCounter + 1
set theGroupCounter_str to theGroupCounter as string
set GroupName to (GroupBaseName & " (Group: " & theGroupCounter_str & ")")
set CurrentTarget to create location GroupName in theDatabase
set theItemCounter to 1
end if
end repeat
on error error_message number error_number
if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
end try
end tell