Deleting files on a mounted disk

Whe I mount a disk in the course of my scripts execution and then attempt to delete a file in it after the script is done with it, I get a pop-up window informing me that the file will be deleted immediately and asks if I wish to continue. And of course, I do wish that.

The question I have is - in order to deal with that window via scripting when it pops up do I need to use GUI scripting or is there some way to force a delete and suppress the pop up?

Without seeing your script try using a try block.

try
– your script here
end try

Tom

You won’t see that message if you use unix to delete the file, so use the “rm” command on a file or “rm -R” on a folder.

do shell script "rm " & quoted form of posix path of theFile

I knew there would be a Unix fix.

Regulus6633, what’s a good resource for learning Unix? Is there a website like MacScripters out there for Unix novitiates?

Tom:


	try
		tell application "Finder"
			set z to "CUs/1" -- Script/Block marker
			set lStagingFolder to (gDMTFolder & "Staging:" as Unicode text) -- Get staging folder path
			set lArchives to (gDMTFolder & "Archive:" as Unicode text) -- Get archive folder path
			set LoadZipUtility to load script alias (lScriptsFolder & "ZIP Utility.scpt" as Unicode text)
			tell LoadZipUtility to sZIPFiles(this_folder, lUserName, gDMTFolder, lUserName, gResourcesFolder) -- Make a ZIP archive of inbox
			tell LoadZipUtility to sZIPPER(lArchives, lStagingFolder, lZIPName, lScriptsFolder, lOutboxFolder) -- Make a ZIP archive of staging folder and move to outbox
			delete (every item of folder this_folder) -- Users inbox ************** This is the mounted disk/folder **************
			delete (every item of folder lStagingFolder) -- The all purpose folder (basically a temp folder)
		end tell
		
	on error msg
		my sMyErrorLogger(z, msg, lScriptsFolder) -- Log error
	end try

Here’s a couple places I go for information. The first one is where I initially learned about using unix.

http://www.osxfaq.com/Tutorials/LearningCenter/
http://forums.macosxhints.com/showthread.php?t=40648

Good call, regulus.

FYI, Rectal. (there’s a sentence fragment I never imagined I’d type :lol:) Unix is very powerful, very fast, and very unforgiving! Use extreme caution (even when using “simple” commands like ‘rm’) and definitely don’t try it live 'til you’ve tested it. Last year, I deleted 4 years worth of reference material in about 30 seconds because I mistyped a single character! So I’m not saying don’t do it - just make sure you understand some fundamentals (like - you always need to know where you are in Unix and it’s not always obvious when calling “do shell script”.) I also suggest testing from Terminal and getting comfortable there. You can usually extrapolate your Terminal commands into a “do shell script” fairly painlessly.

To regulus’ list I’d add: http://developer.apple.com/documentation/Darwin/Reference/ManPages/index.html#//apple_ref/doc/framework/manpages
and even though it’s not perfect. a handy utility for reading man pages when your not connected is Man Handler found here: http://geeksuit.com/software/77_0_1_0_M/

Enjoy (and be careful :P)

Jim Neumann
BLUEFROG

Thanks guys,

I bought a book on shell scripting but it turns out I need a book to UNDERSTAND the book. I guess I need the remedial stuff! :smiley: