Finder access to folders

Anyone any idea why this script fail to delete the folder is creates ?
I’m new applescript, so any help appreciated

do shell script “mktemp -d -t backup”
set BackupDir to result

display dialog ("temp backup directory = " & BackupDir) buttons {“OK”}

(* make use of temp dir here… *)

tell application “Finder”
activate
delete every item of folder BackupDir
delete folder BackupDir
end tell

/Pete

Hi Pete,

the easiest way to delete the temp folder is also to use the shell

set BackupDir to do shell script "mktemp -d -t backup"
-- do something
do shell script "rm -r " & BackupDir

If you use the Finder, you must coerce the POSIX path (/path/to) to an colon separated path (path:to:)

set BackupDir to do shell script "mktemp -d -t backup"
-- do something
set BackupDir to POSIX file BackupDir -- coerce POSIX path to file URL

tell application "Finder"
	delete every item of folder BackupDir -- not really necessary
	delete folder BackupDir
end tell

::hangs head in shame::

I’ve actually never used mktemp, but I do have a work around for you. Unles your wed to the ideaa of using it though here is a all Finder example.

tell application "Finder"
	set deskPath to desktop as Unicode text
	make new folder at deskPath with properties {name:"backup"}
	set BackupDir to deskPath & "backup:"
	display dialog ("temp backup directory = " & BackupDir) buttons {"OK"}
	(* make use of temp dir here... *)
	delete every item of folder BackupDir
	delete folder BackupDir
end tell