I got the following version to work. I left in the "say" commands. Using say commands is a good debugging technique.
on open droppedItems
say "on open"
tell application "Finder"
set inputFolder to (container of first item of droppedItems) as Unicode text
set convertedFolderPath to inputFolder & "converted:"
if (exists (folder convertedFolderPath)) then
say "converted folder exists"
set outputFolder to (inputFolder & "/converted/") as text
else
say "converted folder does not exist"
make new folder at inputFolder with properties {name:"converted"}
set outputFolder to the result as text
end if
end tell
say "end open"
end open
---Edit---
Oh, this is tagged with an "Automator" tag. If your code is within an Automator action of "Run AppleScript", then it shouldn't have the "on open droppedItems". In Automator, the script should look like the following:
on run {input, parameters}
-- Enter your scripting here (without the "on open droppedItems" part)
return input
end run
---Edit 2---
OK. I understand that the path was part HFS and part POSIX. The funny thing is that it did work on my computer for both creating a new folder and for detecting that a folder already existed, but here is my code that is fixed to have an HFS path without any part ofis being a POSIX pah:
on open droppedItems
say "on open"
tell application "Finder"
set inputFolder to (container of first item of droppedItems) as Unicode text
set convertedFolderPath to inputFolder & "converted:" ---- changed this ----
if (exists (folder convertedFolderPath)) then
say "converted folder exists"
set outputFolder to convertedFolderPath
else
say "converted folder does not exist"
make new folder at inputFolder with properties {name:"converted"}
set outputFolder to the result as text
say "created folder"
end if
end tell
say "end open"
end open
Mac Pathnames