Setting the visibility of a file - possible?

Is it possible to set the visibility of a file with AppleScript? I’d like to have a droplet that’ll toggle it for file(s) dropped on it.

Thanks,
Dave

If you have Apple’s developer tools installed, you might want to take a look at AdjustVisibility. It uses AppleScript and SetFile and the script is editable.

– Rob

There might be a slight problem with your request…
Once the file is invisible, you won’t be able to see it from the Finder and you won’t be able to drag it onto the droplet to toggle it back to visible.

Thanks Rob, I’ll check that out.

Greg - Yes, that would be problem. Fortunately there is a little program callled inVisibles from mac4ever.de that makes invisible files visible (but translucent) and draggable and otherwise manipulatable.

Dave

Just a heads up on the AdjustVisibilty script that Rob mentioned. That script quits the Finder at the end of the script. (See this thread about adding some code to re-launch the Finder.) Also, AdjustVisibility only sets the visibilty flags of files, which will not make files that start with a dot (e.g.: .tcshrc) visible.

I think the mac4ever.de script named InVisibles uses the ‘defaults’ command to write to the Finders .pist file.

defaults write com.apple.finder AppleShowAllFiles 1

which makes every invisible file visible

defaults write com.apple.finder AppleShowAllFiles 0

will toggle them back to an invisible status. And a restart may be necessary.

If you are just intersted in reading the text of invisible files that start with a dot, then this script may be helpful.

set filePath to quoted form of the POSIX path of (choose folder)
set hidFiles to do shell script "cd " & filePath & ";echo .<^.>*" -- shows hidden dot files only 
if result = ".<^.>*" then -- no hidden files returns this -- a dumb fix, but it works 
	display dialog "No hidden files were found in this folder" buttons {"Cancel"} default button 1
end if

try
	set oldTIDs to AppleScript's text item delimiters
	set AppleScript's text item delimiters to space
	set thelist to text items of hidFiles as list
	set AppleScript's text item delimiters to oldTIDs
on error
	set AppleScript's text item delimiters to oldTIDs
end try

set theChosen to choose from list thelist OK button name "OK" without multiple selections allowed and empty selection allowed
if theChosen = false then return -- thanks Jon
do shell script "cd " & filePath & ";bbedit " & theChosen

The above script requires BBEdit 7.0+ with the bbedit command line tools installed. It will open your selection in a new BBEdit window, if your selection is a hidden directory it will open it in a new BBEdit Disk Browser window.

I’ll check out the finder quiting thread. Since I’ll be rewriting the script as a droplet, that may help.

Yeah, I think that pList alteration is what inVisibles does. It’s a handy little app. Free too!

Thanks for the .file reading script. I don’t have BBEdit and just need the invisibility droplet to help build and debug CD ROMs containing invisible files. But thanks anyway.

If you really want to help me, how about sending some sausage from Elgin? They don’t make it quite right up here in Oregon.

Dave

Got it figured out. And it’s so nifty I made a little app out it!
Behold… Invis-O-Matic!

http://home.comcast.net/~dm_02/IOM.html

Thanks for the help!
(If you encounter any bugs, let me know.)

I see you’ve heard of good ole ‘Elgin Hot Gut’, that’s what we call it down here. It’s good stuff for sure, and I’ve got the bellly to prove it. There’s three shops in town and they do sausage right, Meyer’s Sausage “ store bought but real good, SouthSide BBQ, my second most favorite, and Cross Town BBG, greasy and undeniably the best I’ve ever had.

I downloaded your Invis-O-Matic v1.1 script, nice job “ I like the icon too. There is a System hack I did a while back that adds a “Quit Finder” menu item to the Finder Menu which I chose to use rather than double clicking your app to make a folder I hid visible again. Since your script was saved as a run only app, I wasn’t sure whether it would make all of my invisible files visible, which I didn’t want. defaults write com.apple.finder QuitMenuItem 1
plug in a 0(zero) to remove it.

Double-click on it! I dare you!

What it does is toggle the AppleShowAllFiles finder attribute. This allows you to see all of the invisible files without changing their visibility flag. They show up semi-transparent. Double-click again and all are invisible again.

This works via:

defaults write com.apple.finder AppleShowAllFiles '1'

I don’t even want to click on those BBQ links because I know there are just going to be photos of piles of meat that I can’t get to anytime soon!

Well ya ain’t ‘Double Dare’d’ me yet! (and I already ran it)
Anyhow, I hate running scripts that are saved as run only and I usually stay as far away from them as I possibly can. It’s my personal preference to share my AppleScript code in the hope that others might share their techniques and ideas, which in turn helps us all improve our skills. That’s just my way, and I’m not opposed a scripter/programmer protecting their code.

As a precaution, I always use the terminal.app to look thru the readable strings in scripts that are saved as run only before I feel safe enough to run them. If I find anything curious, or questionable, I simply trash the file in question without hseitation…

% strings -a Invis-O-Matic.app/rsrc | more – returned the info I needed to know.

See the link below for some interesting info on run only scripts…

http://bbs.applescript.net/viewtopic.php?t=4635&highlight=strings

Enjoy, and thanks Dave – happy scripting…

Got ya. Being a complete Applescript newbie I didn’t understand exactly the options when saving as an application.

The script should now be readable:

http://home.comcast.net/~dm_02/IOM.html

Just a note to say that this has been updated again:

http://home.comcast.net/~dm_02/IOM.html

If you drop a folder on it, it will now recursively make files contained therein either visibile or invisible.

Dave