|
|
AppleScripting invisible files
|
|
|
|
Mac Elite
Join Date: Oct 1999
Location: Walnut Creek, California
Status:
Offline
|
|
Can you do that? I want to write a script to toggle a folder invisible or visible, but I don't know how.
It would also be nice to have a script that could change the creator of files, but I wouldn't know how to that either. Doesn't the finder have control of these things?
I checked through older forums and documentation but still could not find anything about does this stuff.
Too bad ResEdit isn't scriptable
|
|
|
|
|
|
|
|
|
Junior Member
Join Date: Oct 1999
Location: Edmonton, Alberta, Canada
Status:
Offline
|
|
here's something to get you going, hope it helps
-- To use this script's code as a shell for another Creator/File type Changer,
-- change the creator code & file type and save this Application as a new application (preform a Save As)
-- (its called a droplet, because you drop files on it)
on open theFiles -- theFiles - the variable that the files path(s) are stored in when you drop files on this droplet
-- called when files are droped on this Droplet
try
-- trys to preform the following lines of code
repeat with aFile in theFiles -- aFile - one of the files, if you droped multiple files on this droplet
-- the repeat statement cycles through all the files if you droped multiple files on this droplet.
tell application "Finder"
-- sets what appliucation will be the focus the following lines
set creator type of aFile to "????" -- the creator code
-- sets the creator code to "nothing"
set file type of aFile to "TEXT" -- the file type
-- sets the file type to TEXT
end tell
-- terminates the application "finder" as the focus of the script
end repeat
-- terminates the repeat loop
on error errorMessage number errorNumber
beep
display dialog "Error: " & errorMessage & return & "Error ID: " & errorNumber buttons {"OK"} default button {"OK"} with icon �constant Altpof the error and the resulting error ID
end try
-- ends the try statement
end open
-- terminates the script
------------------
-- An idea is salvation by imagination.
-- Frank Lloyd Wright
-- 30 --
|
-- An idea is salvation by imagination.
-- Frank Lloyd Wright
-- 30 --
|
|
|
|
|
|
|
|
Junior Member
Join Date: May 2001
Status:
Offline
|
|
yeah... the Finder wants no part of invisible files and folders in a script - just doesn't seem to know what to do with them. luckily, there are a couple of scripting additions that are a little more resourceful... one's called "Better Info For" & is available at http://www.osaxen.com/?id=better_info
Drop the scripting addition, "BetterInfoFor", in the "Scripting Additions" folder in the "System Folder" & set up a script such as:
Code:
set MyFolder to "Macintosh HD:MyDocuments" -- change to the path to the folder of interest
if visible of (info for alias MyFolder) is true then
setBetterInfoFor file MyFolder setting {bi_IsInvisible:true}
else
setBetterInfoFor file MyFolder setting {bi_IsInvisible:false}
end if
This will toggle the visibility of the folder specified by MyFolder (in this case, a folder (although the scripting addition prefers calling everything a "file") called "MyDocuments" at the root level of the disk called "Macintosh HD"). There's also another scripting addition called "File Visibility" that has similar functionality, but I prefer "Better Info For" since it also allows setting other Finder flags and file type & creator info at the same time (although the Finder's ok with setting these also, using a setup like MacCanada's droplet above). For more info, maybe check the dictionary of the scripting addition in Script Editor, or post back here. Hope this info helps
cheers, acur
|
|
|
|
|
|
|
|
|
Dedicated MacNNer
Join Date: Nov 1999
Location: Georgetown, Demerara, Guyana
Status:
Offline
|
|
Hi all,
Just to add one more to the mix, the ubiquitous Akua Sweets OSAX tends to do a better job of retaining a folder's window position & size when its visibility is toggled. [This is a minor boon to those of us who're anal about our painstakingly cascaded folder windows, at least under Mac OS Classic. ;-) As I've recently discovered, the Mac OS X Finder doesn't automatically honour the catalogue info for folders, such as window sizes & positions or view settings.]
In any event, with Akua Sweets installed, one could toggle a folder's invisibility like this:-<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>set theFolderPath to <font color = red>" someVolume: someFolder: ... : someSubfolder:"</font>
set theFolderInfo to (extended info <font color = green>for</font> (file theFolderPath))
set bIsFolderInvisible to (invisible status of theFolderInfo)
set (invisible status of theFolderInfo) to (not bIsFolderInvisible)
apply catalog info theFolderInfo to (file theFolderPath)</font>[/code]
[What's up with all this funky HTML-style colouring for UBB Code...?!]
Regards,
--Paul
[ 07-26-2001: Message edited by: Paul Crawford ]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|