Re: Finding and deleting specific extensions
Re: Finding and deleting specific extensions
- Subject: Re: Finding and deleting specific extensions
- From: Henry L Miller Jr <email@hidden>
- Date: Fri, 19 Sep 2003 14:02:51 -0600
At 22:08 -0700 9/18/03, Christopher Nebel wrote:
>
On Sep 18, 2003, at 1:21 PM, Henry L Miller Jr wrote:
>
>
>What has stumped me to date, is how to have some statements that
>
>access some properties of the file class that ARE defined in OS X
>
>10.2.6 Finder, but ARE NOT defined in Finder 9.1 remain accessible
>
>when compiled on an OS X machine, and be ignored at compilation
>
>time by an OS 9 machine.
>
>
>
>In the tell block below, the properties "name extension",
>
>"extension hidden", and "displayed name" work well in OS X, but
>
>these properties are not defined in OS 9. So, even though I don't
>
>try to execute the commands accessing these properties unless I'm
>
>in OS X 10.2.x, I can't run the script on an OS 9 machine.
>
>
>
> tell application "Finder"
>
> -- get the path to source file
>
> set srcPath to ((container of file srcFile) as string)
>
>
>
> set versNum to (get the version) as number
>
> -- get the displayed name, name
>
>extension, and extension display condition in OS X
>
> (*
>
> need to find a way to "block"
>
>these from compile process - OS 9 Finder complains
>
> *)
>
> if (versNum 10.2) then
>
> set nameExt to name extension of file srcFile
>
> set hiddenExt to extension hidden of file srcFile
>
> set dispName to displayed name of file srcFile
>
> end if -- {versNum}
>
> end tell -- {Finder}
>
>
>
>
>
>The purpose of this exercise is to have one script that will
>
>operate on either platform (OS X
>
>or OS 9) without having to edit the code and comment in/out a block of text.
>
>
>
>Any ideas?
>
>
If you save the script as a compiled script (as opposed to plain
>
text), then you should be able to either avoid the troublesome
>
statements using an "if", or put them in a "try" block and handle
>
the failure in Mac OS 9. If your "if" isn't working, then there is
>
apparently something wrong with your test.
>
>
If you save the script as plain text (and therefore compile it each
>
time you run it), then you'll need to do something trickier, like
>
using raw property codes. However, there are very few advantages to
>
doing this, so one wonders why you don't use a compiled script
>
instead.
>
>
>
--Chris Nebel
>
AppleScript Engineering
I had tried both compiled script and compiled application versions of
my larger script on the OS 9 side, and both encountered errors due to
the statements in "if" block above. However, as I've now discovered,
those tests were not completely appropriate, as I was using an
incorrect test that always evaluated to "true", regardless of which
version of Finder was running.
My initial test was phrased as:
tell application "Finder"
set finderVers to version
if (finderVers >= 10.2) then
do OS X stuff...
This syntax evaluates properly in OS X, but in OS 9.1, the comparison
of "finderVers" to "10.2" also evaluates as true! This caused both
the compiled application and script to enter the if block, and then
execute the statements only appropriate for OS X Finder 10.2. It is
a good lesson to me to examine the values of variables on both
platforms, and examine my development diagnostics not only on OS X,
but also on OS 9.
My immediate task with the script of which the "tell" block is a
part, is to have an embedded Applescript in Filemaker Pro, that will
make an automated backup of the Filemaker database, triggered by
criteria embedded in the Filemaker Pro script. Filemaker does not
appear to handle files, folder and Finder objects with as much
versatility as AppleScript.
I also wish to take the building blocks of this script, many written
as broad-use subroutines, and begin to build a library of AppleScript
subroutines and scriptlets, that I can then use in other scripts,
without having to continually cut, paste, rewrite, etc. I'd like to
build up a set of AppleScript Libraries to use on my systems here - I
administer about 30 Macs, a handful of Unix-only workstations, and a
couple of Windows machines.
So, for this last purpose, as a building block for larger scripts yet
to be compiled, and perhaps even for the Filemaker implementation,
where the script is probably stored as text, it appears to me that I
need to go with either raw property codes, or use the "manual comment
out". Of the two, I think I prefer to use the former, along with
static comments that describe what the raw codes describe.
My thanks to you, and to Emmanuel, for your help. Although I don't
yet know how to determine the raw property codes, with the Appendix
from the Satimage site, and some hints from other posts I've seen, I
suspect I'll get it done.
regards,
H. LeRoy Miller, Jr.
NOAA Aeronomy Lab
_______________________________________________
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.