I’ve got a nested fonts folder and I’d like to move all the fonts to one folder.
Can someone give me some hints how to do this. It’s been along time since I did any scripting and my brain has frozen!
I’ve got a nested fonts folder and I’d like to move all the fonts to one folder.
Can someone give me some hints how to do this. It’s been along time since I did any scripting and my brain has frozen!
How’s this?
tell application "Finder"
set searchpath to choose folder
set pathtext to searchpath as text
set filepaths to (every file in entire contents of folder searchpath whose kind contains "Font") as alias list
repeat with eachfile in filepaths
set thisfile to eachfile as text
set filename to name of eachfile as text
if pathtext & filename ≠thisfile then
move eachfile to searchpath
end if
end repeat
end tell
.or this, it uses Spotlight metadata to find the files
set SourceFolder to quoted form of POSIX path of (choose folder with prompt "Choose source base folder")
set DestinationFolder to quoted form of POSIX path of (choose folder with prompt "Choose destination folder")
do shell script "mdfind -onlyin " & SourceFolder & " -0 'kMDItemContentTypeTree = \"*font*\"' | xargs -0 -J {} mv {} " & DestinationFolder
Hmm, I’d assumed the OP wanted to move all fonts out of subfolders into the enclosing folder. If you want to move them to some other folder entirely, you can do it with pure Applescript:
tell application "Finder"
set searchpath to choose folder with prompt "Source"
set destpath to choose folder with prompt "Destination"
set filepaths to (every file in entire contents of folder searchpath whose kind contains "Font") as alias list
move filepaths to destpath
end tell
no problem, the script even deletes the empty folders.
entire contents could be pretty slow
set SourceFolder to (choose folder with prompt "Choose source folder")
set POSIXSourceFolder to quoted form of POSIX path of SourceFolder
do shell script "mdfind -onlyin " & POSIXSourceFolder & " -0 'kMDItemContentTypeTree = \"*font*\"' | xargs -0 -J {} mv {} " & POSIXSourceFolder
tell application "Finder" to delete every folder of SourceFolder
Yikes! What if they’re not empty? They could have had more than font files.
Thanks for the posts!! These have helped loads!!