Folder Actions / Dialogue Warnings

Hello, and yes, this is my first post. It’s very noob, but very necessary.

I’ve been helping my friends set up an office for a bunch of artists, writers, actors and other theater people. They are all very creative but not a one of them is computer literate.

One of the problems they have is screwing around in directories that they shouldn’t be screwing around in. For instance, I’ve had to recover photos from iPhoto way too many times. I even have a hard copy of Eudora’s settings folder (foolishly located in Documents) so that I can recover serious problems when people screw around in there.

Training with this group can only go so far, so I’ve been looking, for starters, at using folder actions to direct and warn them should they ohhh let’s say, open the iPhoto library. Something that says:

Caution! Making changes, deletions or modifications to this folder and it’s contents may cause serious problems to one or more programs.

I haven’t used appleScript much, but I am a decent coder and I played around for a while trying to get a simple alert_message to open and warn them that they were entering dangerous territory. They all have failed.

Can anyone help me with a quick script to attach as a folder action that displays an alert message such as the one above?

Oh, and I’m sure I’ll have a lot more questions. We’re getting Remote Desktop 3, Aperture, and a whole lot more.

Thanks!

Model: eMacs 800mhz+
AppleScript: 1.9.3
Browser: Safari 312.6
Operating System: Mac OS X (10.3.9)

Okay, I figured it out and I apologize for asking such an inane question. I have a lot of information to glean but I’ll get it :smiley:

on opening folder this_folder
	tell application "Finder"
		set theResult to display dialog "Caution! Making changes, deletions or modifications to this folder and it's contents may cause serious problems to one or more programs." buttons {"OK"} default button "OK" with icon 0
	end tell
end opening folder

Pretty simple stuff. ‘Hello World,’ even. But, enough to get me started.

lordGracen,

You may have better luck simplifying the experience for them. Any file or folder you wish to protect you can hide. Why warn of the iPhoto Library when you can prevent them from seeing it? :slight_smile: You can hide items with a commad line tool from the Developer Tools (setfile). There are probably other GUI tools also (check VersionTracker and MacUpdate).

Hiding
~/Library
~/Pictures/iPhoto Library
~/Public (unless they use it)
~/Sites (not necessary, but why not simplify)

would help a lot. Documents, Movies, and Music: with daily backup, those would be well protected. Applications? You probably have this setup: as non-admin users, apps are safe. Parental Controls? :slight_smile: Why not.

Doing such things should make it a more pleasant experience for everyone.

Gary

good idea guyen,

here is a script i wrote a while back to create the ‘.hidden’ file on the Mac. i believe you can use it to hide anything you want. although i’m posting, “as is” you could easily script it to ask what file you’d like to hide, and of course add the thing i left out of the original: tell the finder to restart from within the script:


do shell script "#!/bin/sh

# This script checks for a missing .hidden file and makes one if needed

# First, does our directory exist?

	if [ -d /.hidden ]; then
echo $1: /.hidden exists! You don\\'t need to create a .hidden file. 1>&2
exit 1
	fi"

set normalCommand to "#!/bin/sh

# If it exists, get into the directory
cd /;

cat > /.hidden << EOF
#Files in this list will be invisible to the Finder
automount
bin
cores
Desktop DB
Desktop DF
Desktop Folder
dev
etc
lost+found
mach
mach_kernel
mach.sym
private
sbin
tmp
Trash
usr
var
VM Storage
Volumes

EOF

chown root:admin /.hidden
chmod 777 /.hidden

exit 0"

do shell script "sh -c " & quoted form of normalCommand with administrator privileges


set stringToBeDisplayed to "This script is finished.  You now have a new .hidden file.  You'll need to restart the Finder for the changes to show."
set tempVar to display dialog stringToBeDisplayed buttons {"Exit"} default button "Exit"
set theButtonPressed to button returned of tempVar

NOTE: i believe these are all root level. you may have to give a path to the file, although i think wildcards should work.

Fantastic advice.

I’ve been looking for scriptbuilders and some of the other associated sites for more simple actions such as this. One of the more complex tasks I need to achieve for this group of savants is getting them to save their files in appropriate places, and not all over the desktops.

What I’d like to do is create a script that starts both when a file is saved onto the desktop or when one is dragged onto an associated icon. There are four computers in this office (each of which, until now, has had it’s own filing ‘system’).

I would like to set up a file ‘server’ on one of the computers and I would like this script to prompt them to save in one of the directories I set up. SCRIPTS, OPERATIONS, FINANCIAL, FUNDANDGRANTS, etc. Clicking on the OPERATIONS button would open another menu of the sub-directories: LICENSES, PERMITS, etc.

Simple click and done. Over the network.

I’m not asking for the script to do this, but a pointer in the right direction. Are there existing scripts like this that I could modify for our purposes? Is there a decent tutorial I can read (I’ve seen what amounts to hundreds - the pure volume of this information is a little daunting) on this subject?

Finally, any other advice would be helpful. Would this little scriplet purely activate within the finder, or will it recognize when, for instance, Word is saving something?

waltr,

looks good. I checked my HD and I have no /.hidden (or ~/.hidden) I believe items hidden with setfile change a file attribute. Your script could still work by running “/Developer/Tools/SetFile -V” & finderItem.

I thought of another thing. You could attach a folder action to ~/.Trash. Test for add folders and move them back.

Gary

hi guyen,

yes, i do like the SetFile option, but i wrote the ‘.hidden’ file (which is now a depreciated OS X method for hiding things) because of a bug in SetFile: if you do a SetFile on an alias, it will SetFile on the original, but not the alias–this can be a pain.

most OS X machines (i believe 10.3 or later) will not have a ‘.hidden’ file, so it’s an ok method if a) you want it quick and don’t mind dirty, or b) you need to hide aliases.

hi lg,

since the Desktop is just a folder on OS X, i think you could accomplish this with a ‘Folder Action’ script and some judicious ‘if then’ statements.

additionally, you’ll want your script to ‘mount’ the volume over the network that it will save to (if it’s not already mounted), and then create or follow any filesystem organization that you may want to implement.

HTH.

Not to get off topic since I am a big proponent of AppleScript, but it sounds like you might have an easier job setting up these users’ log in accounts with restictions. I haven’t done too much of this but I am pretty sure you could set up their accounts so they can use the apps they need but not have access to important things.

Just thought I would throw that out there as an option to look into.

-Matt