(Some of you have seen this script before but now I have a different question)
This script does the following:
drop a file on the folder “Sort”
the file will be moved to a subfolder that has the name of the file’s extension.
If the subfolder does not exist, then create is.
(files without an extension are moved to folders named Classic filetype)
Example:
foto.jpg goes into the subfolder “jpg”
If folder “jpg” does not exist, then create it.
Everything works fine!
Just one little thing:
if the file foto.jpg allready exists in folder “jpg” then it should be overwritten!
But this does not happen. It ends up in the folder “Sort” !
Why does “move f to alias fullpath with replacing” not work???
on adding folder items to this_folder after receiving added_items
set thepath to this_folder as string
copy thepath to basepath
repeat with f in added_items
set this_info to info for f
if not folder of this_info then
set fstring to f as string
set olddelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"."}
set extstring to get last text item of fstring
set AppleScript's text item delimiters to olddelimiters
if extstring = fstring then -- there is no extension
set extstring to ("Classic " & file type of this_info)
end if
set fullpath to basepath & extstring
try
move f to alias fullpath with replacing -- REPLACING does not work!!!!!
on error -- if there is no folder, then make the folder
tell application "Finder" to set x to make new folder at this_folder with properties {name:extstring}
move f to alias fullpath
end try
end if
end repeat
end adding folder items to