I have a folder with over 2000 misc stuff in it...I want to go through it, but I'd like to first sort it into smaller folders to make it a bit easier and help the computer out.
I found an applescript that will sort the items into folders by full date, year/month/date.
That's too fine grain for my needs, so I'd like to organize them by Year/Month.
Naively I think I can alter the script I found to do it, but I need to learn the scripting code used in the the two do shell script lines.
So, my question(s) is will this be as easy I think it should be? Any advice on the code changes? Is there a better way to accomplish what I want?
From: http://hints.macworld.com/article.php?story=20090501221803809
I found an applescript that will sort the items into folders by full date, year/month/date.
That's too fine grain for my needs, so I'd like to organize them by Year/Month.
Naively I think I can alter the script I found to do it, but I need to learn the scripting code used in the the two do shell script lines.
So, my question(s) is will this be as easy I think it should be? Any advice on the code changes? Is there a better way to accomplish what I want?
Code:
tell application "Finder"
set mifold to choose folder
set filelist to every file of mifold as list
set foldlist to every folder of mifold as list
repeat with i from 1 to number of items in filelist
set subj to item i of filelist as alias
set epoch to (do shell script "stat -f \"%B\" " & (quoted form of (POSIX path of subj)))
set caldate to do shell script ("date -r " & epoch & " \"+%Y-%m-%d\"")
if not (exists folder caldate of mifold) then
make new folder at mifold with properties {name:caldate}
end if
try
(* try ignores errors from locked files *)
move file subj to folder caldate of mifold
end try
end repeat
repeat with j from 1 to number of items in foldlist
set subj to item j of foldlist as alias
if name of subj does not start with "200" then
set epoch to (do shell script "stat -f \"%B\" " & (quoted form of (POSIX path of subj)))
set caldate to do shell script ("date -r " & epoch & " \"+%Y-%m-%d\"")
if not (exists folder caldate of mifold) then
make new folder at mifold with properties {name:caldate}
end if
try
(* try ignores errors from locked items *)
move folder subj to folder caldate of mifold
end try
end if
end repeat
end tell
From: http://hints.macworld.com/article.php?story=20090501221803809
Last edited: