property itemPath : "LutherFuller-2:untitled outer:untitled inner:" -- this is a usb flash drive
-- simulates data available in the preference file
on run
set selfRef to (path to me)
tell application "Finder"
set aliasAlias to (some alias file of container of selfRef) as alias
try
set targetFolder to (original item of aliasAlias) as alias
-- errors because original item is on an unmounted (image) disk
on error
try
ignoring application responses
open aliasAlias -- (mounts the image disk) and opens window of target folder
-- fail or cancel password --> Delete Alias / Fix Alias dialog
end ignoring
delay 1
set targetFolder to (original item of aliasAlias) as alias -- no error
close window of targetFolder -- closes the unwanted window
on error
try
set AppleScript's text item delimiters to {":"}
set diskName to (text item 1 of itemPath)
if exists disk diskName then
display dialog ("Can not find the item on the disk \"" & diskName & "\"") buttons {"OK"} default button 1
return
else
display dialog "The disk \"" & diskName & "\" is not mounted." buttons {"OK"} default button 1
return
end if
on error errText number errNr
"Error = " & errNr & return & errText
display dialog the result
end try
end try
end try
display dialog "OK..." default answer targetFolder as text
end tell
end run