“Multimedia Collector”. WOW! What is it?
the script collects files given a certain suffix and puts them together and aside similar files into a common folder.
Feel free to improve my script, and don’t be shine to post your suggestions and improvements.
-JO
–Edit
i forgot: would be nice to get the CFBundleTypeRole values. Maybe its some useful info to classify apps too. I’m unable to gather it because System events seems not able to read nested plist strings.
#Multimedia Collector
#finder
#scpt
#0,03
-----------------------------------------------------------------------------------
#TIP:
#categories are identified as:{"Audio", "Code","Docu", "Image","Package","Video", "Web"}
#
#CONCEPT:
#Collect quickly various files and store them in common category folders
#
#TODO:
#
#Developed by Joy, 11.08.12
#iScripts -Crafted by Joy- http://gothicage.deviantart.com/
-----------------------------------------------------------------------------------
script media_ls
property audio_list : {"aiff", "aif", "m3u", "mp3", "mp2", "wav", "wave", "mid"}
-----------------------------------------------------------------------------------
property img_list : {"jp2", "jpg", "jpeg", "tif", "tiff", "png", "gif", "pict", "QuickTime Image", "psd", "xcf", "odg", "ptg", "odp", "svg", "xpf", "ppt", "bmp", "tga"}
-----------------------------------------------------------------------------------
property web_list : {"mht", "webloc", "torrent", "url", "com", "html", "htm", "xhtml", "webarchive", "shtml", "mailtoloc"}
-----------------------------------------------------------------------------------
property Office_list : {"odt", "ods", "pdf", "pages", "rtf", "rtfd", "txt", "doc", "docx", "mind", "numbers", "compta", "skim", "csv", "xls", "pastor", "pvoc", "abbu", "icbu", "textClipping", "pictClipping", "soundClipping", "ics", "slipbox", "cddt", "chm", "epub", "blend", "obj", "dxf", "skp", "kmz", "fla", "odp", "x", "bvh", "kml"}
-----------------------------------------------------------------------------------
property Video_list : {"mov", "avi", "wmv", "swf", "mpg", "flv", "mp4", "key", "m4v"}
-----------------------------------------------------------------------------------
property custom_list : {"Log File", "scpt", "applescript", "scptd", "py", "pyc", "rb", "ivc", "exe", "msi", "scm", "workflow", "action", "caction"}
-----------------------------------------------------------------------------------
property save_list : {"sit", "sitx", "dmg", "img", "pkg", "mpkg", "zip", "gz", "tgz", "hqx", "bz2", "tar", "rar", "disc", "burn", "iso", "toast", "icontainer", "dcmd", "air", "cbr", "7z"}
-----------------------------------------------------------------------------------
property cat_ls : {audio_list, img_list, web_list, Office_list, Video_list, custom_list, save_list}
end script
property htm_ls : {"htm", "html", "xhtml", "shtml"}
property code_of : {"Audio", "Code", "Docu", "Image", "Package", "Video", "Web"}
set {sl1, sl2, sl3, sl4, sl5, sl6, sl7} to {{}, {}, {}, {}, {}, {}, {}}
set sl_ls to {sl1, sl2, sl3, sl4, sl5, sl6, sl7}
tell application "Finder" to set frfl to folder of front window
set frfl to frfl as text
set fr_ls to list folder frfl without invisibles
set htm_y to false
--collect files
repeat with a in fr_ls
set nex to extract_nex(a)
set dd to 0
repeat with get_cat in media_ls's cat_ls
set dd to dd + 1
if nex is in get_cat then
if nex is in htm_ls then
if htm_y is false then set htm_y to true
end if
set {get_slot, find_folder} to {item dd of sl_ls, item dd of code_of}
try
do shell script "mkdir '" & POSIX path of (frfl & find_folder as text) & "'"
end try
copy alias (frfl & a as text) to end of get_slot
exit repeat
end if
end repeat
end repeat
--move things
set dd to 0
repeat with a in sl_ls
set dd to dd + 1
set find_folder to item dd of code_of
if a is not {} then
tell application "Finder"
try
make new folder at alias frfl with properties {name:find_folder}
end try
try
move items in a to alias (frfl & find_folder as text)
end try
end tell
end if
end repeat
--move web resources
if htm_y is true then
set htm_ress to {}
repeat with a in fr_ls
if a ends with "_files" then
copy alias (frfl & a as text) to end of htm_ress
end if
end repeat
try
tell application "Finder" to move items in htm_ress to alias (frfl & "Web" as text)
end try
end if
on extract_nex(o_nm)
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "."
set cc to number of text items of o_nm
set txt2 to last text item of (get text items of o_nm)
set AppleScript's text item delimiters to tid
return txt2
end extract_nex