So we all have files on our desktop, that we know belong in the correct folder, but sometimes sorting maybe hundreds of files is too much.
This is what I call ReRoute
So, you have 2 files, me.jpg, and work.doc
You drag both of these files onto the script and the following happens.
Script will look to see if it has ever seen that extension before, in this case .jpg and .doc
If it hasn’t, it will ask you what folder you would like saves those kind of files in. The files will then be moved to said folder
It will walk through all the files dropped until it finds a new extension it does not recognize, until all files are handled.
If you make a mistake, simply run (double click) the script and it will allow you to reassign a new folder to any given extension.
If things get really out of control, you can choose “Panic!” and it will wipe all mappings.
Enjoy!
property dotext : {}
property dotextloc : {}
property ver : "110426"
on open thefiles
tell application "Finder"
repeat with i from 1 to length of thefiles
--if last character of (item i of thefiles as string) ≠":" then
set x to name of item i of thefiles
if x contains "." then
set tempfile to last item of (my stringtolist(x, "."))
--display dialog tempfile as string
if dotext does not contain tempfile then
set end of dotextloc to choose folder with prompt "Please choose the folder you want \"" & tempfile & "'s\" saved"
set end of dotext to tempfile
end if
repeat with i2 from 1 to length of dotext
if item i2 of dotext = tempfile then
move (item i of thefiles) to (item i2 of dotextloc) with replacing
end if
end repeat
else
display dialog "The file " & x & " does not contains a .ext, so it will be ignored." with title ver
end if
--end if
end repeat
end tell
end open
on run {}
my _editor()
end run
on _editor()
set breturn to button returned of (display dialog "Fix a ReRoute" buttons {"Cancel", "Panic!...", "Fix One..."} default button "Fix One..." with title ver)
if breturn = "Panic!..." then
set breturn2 to button returned of (display dialog "This will delete all bindings to files?" buttons {"Cancel", "Continue..."} with title ver)
if breturn2 = "Continue..." then
set dotext to {}
set dotextloc to {}
end if
end if
if breturn = "Fix One..." then
if length of dotext ≠0 then
set x to 0
set dotextTOFIX to (choose from list dotext with title ver)
repeat with i3 from 1 to length of dotext
set x to x + 1
if (item i3 of dotext as string) = (dotextTOFIX as string) then
exit repeat
end if
end repeat
if x ≠0 then
set tfolder to (choose folder with prompt "Current Path for \"." & (item i3 of dotext as string) & "\"
" & item x of dotextloc)
set item x of dotextloc to tfolder
end if
else
display dialog "You must add a .ext before you can edit them!"
end if
end if
end _editor
on stringtolist(theString, delim)
set oldelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to delim
set dlist to (every text item of theString)
set AppleScript's text item delimiters to oldelim
return dlist
end stringtolist
on ListToString(theList, delim)
set oldelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to delim
set alist to theList as string
set AppleScript's text item delimiters to oldelim
return alist
end ListToString