Re: Finding only visible files...
Re: Finding only visible files...
- Subject: Re: Finding only visible files...
- From: Kai <email@hidden>
- Date: Thu, 12 Jun 2003 04:33:52 +0100
on Wed, 11 Jun 2003 07:10:12 -0700, "Domains4Days.com" wrote:
>
On 6/9/03 10:18 AM, "Domains4Days.com" <email@hidden> wrote:
>
>
> I am using the line below and to search for a file. Currently, the dialog
>
> window is finding both visible and invisible files. I would like to limit
>
> the search to only visible files. How can I accomplish this?
>
>
>
>
>
> set thefilepath to (choose file)
>
>
>
Does anybody have any ideas how to view ONLY visible files and not see
>
invisible ones? If there is no way to do this, please let me know this
>
also...
Not specifically. However, you can limit access to files by specifying up to
4 file types - such as:
-------------------
set theFileAlias to choose file of type {"TEXT", "PICT", "PDF ", "ttro"}
-------------------
or:
-------------------
set theFilePath to (choose file of type {"APPL", "APPC", "cdev"}) as string
-------------------
or:
-------------------
set theFile to (choose file of type {"LINK", "NSPL"}) as file specification
-------------------
As Michelle pointed out (I wrote the rest of this message before I saw her
reply), 'choose file of type {...}' will not show invisible files. (To
demonstrate this, I made a file of type "TEXT" invisible and then ran:
choose file of type {"TEXT"}. The resulting list did not include the file
that I'd hidden.)
To use 'choose file of type {...}' in your script, you obviously need to
specify the desired file type(s). If you're not sure about the 4-character
code for a particular file, try running something like this:
-------------------
(info for (choose file))'s file type
-------------------
- and choose a file of the appropriate type. Script Editor's Result window
should then display the relevant code for the chosen file.
If the 'choose file of type {...}' method still doesn't do exactly what you
want, I suppose you could always try adapting Standard Additions' 'choose
from list' - although (in this context) it's a bit of a compromise, since:
1) to access *any* file on disk, you need to start navigating from the top
2) there's no simple way to navigate back up through a file hierarchy
3) there are no icons to help identify folders/file types
However, if you're interested in exploring such an approach, this might help
to get you started:
--===========================================================
chooseItem from (path to startup disk) -- amend as required
to chooseItem from thisFolder
set theChoice to choose from list (list folder thisFolder without
invisibles) with prompt "Choose an item:"
if theChoice is false then error number -128 -- user cancelled
set chosenItem to alias ((thisFolder as string) & theChoice)
set i to info for chosenItem
if i's folder and not i's package folder then return chooseItem from
chosenItem
chosenItem
end chooseItem
--===========================================================
-------------------------------------------------------
(Any wrapped lines abutting the left edge of the window
should be reconnected to the end of the previous line)
-------------------------------------------------------
--
Kai
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.