• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Networking / AS query
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Networking / AS query


  • Subject: Re: Networking / AS query
  • From: kai <email@hidden>
  • Date: Thu, 18 Nov 2004 01:43:13 +0000


On Mon, 15 Nov 2004 17:19:29 -0000, James Naylor wrote:

I wrote a handy applescript to archive out plain text from our indesign
pages, which works pretty well. The script parses the text for links, gets
job ticket files for the link and outputs a formatted text archive with some
metadata prepended to it.


On one of the magazines it is used on, the job ticket files are in eight or
so nested folders on a Windows 2000 server. To search those folders, I use:


=== begin script snippet ===
tell application "Finder" to set FolderList to get the name of every folder
of folder jtServerPath
repeat with thisFolder in FolderList
set thisSubFolder to jtServerPath & ":" & thisFolder as string
try
tell application "Finder" to set filelist to (get the name of every
file of folder thisSubFolder whose name = (jimmyVar & ".jt")) as list


repeat with thisFileName in filelist
set thisPath to (thisSubFolder as string) & ":" & thisFileName
as string
end repeat
end try
end repeat


set jobTicketPath to thisPath
=== end script snippet ===

(where jtServerPath is previously specified - a location on the file server
- and jimmyVar is the name of the job ticket file I am looking for).


This snippet has worked well up until now, when the machines have been
upgraded to OSX. Previously, the search of the eight (or so) folders (with
a couple of thousand files in total) has taken about 6 or 7 seconds. Now,
in OSX, the same search takes about 38 seconds. The OS9 machines is a b/w
G3, the OSX machines a Quicksilver G4 (256MB ram / 733 MHz processor). Both
machines are connected to the same Gig ethernet VLAN (in fact, they are
connected into the same switch).


(I also tried the script on another G4 in another vlan, but with 1GB ram -
it took even longer - approx. 70s!)


Do these (repeatable) results point to changes in applescript between 9 / X;
changes in the Finder between 9 / X (which I suspect), or is it something
else entirely (our network, or my dodgy scripting, for example!).


Sorry for the verbosity, but anybody's thoughts would be appreciated...

While I believe you've been offered a couple of clues on this James, I just had a look back at your snippet to see if something more specific might help you to move things along a bit...


If I understand your description and snippet correctly, you're trying to get the path of the first/only file of a given name (jimmyVar) from somewhere in a set of subfolders within a main folder (jtServerPath). If that's the case, then perhaps there are a couple of tweaks that might help to speed up the search.

The above code uses the Finder to get the names of subfolders and files, concatenating them with previously identified paths. However, there are probably faster ways. It's also a good idea to escape a repeat loop (using while/until/exit/return) as soon as the required condition is met.

If you want to use the Finder, you could ignore file/folder names and use Finder references instead - something like this:

----------------------

to getPath of n from p
	set n to n & ".jt"
	tell application "Finder" to repeat with f in (get folder p's folders)
		if exists f's file n then return (f as string) & n
	end repeat
	error "The file \"" & n & "\" could not be found."
end getPath

set jobTicketPath to getPath of jimmyVar from jtServerPath

----------------------

If there's little risk of files being mixed in with folders, etc., you could (as Simon suggested) speed things up further by using 'list folder' from standard additions. (Since distinguishing files from folders with 'get info' could slow things down again, I'd try to avoid it in this situation.) Anyway, in case an example might help...

----------------------

to getPath of n from p
	set p to p & ":"
	set n to n & ".jt"
	repeat with f in list folder p without invisibles
		set x to p & f
		if n is in (list folder x without invisibles) then return x
	end repeat
	error "The file \"" & n & "\" could not be found."
end getPath

set jobTicketPath to getPath of jimmyVar from jtServerPath

----------------------

(In both examples I've assumed, from the way that your original snippet seems to work, that the variable 'jtServerPath' is the path to a folder - but that it does not yet include a trailing ":". I've also retained the variable 'jimmyVar', the value of which is a filename with no extension.)

I'll leave it up to you to carry out any network testing. However, for either suggestion on a local disk, the speed bump over the original method is pretty significant (20-60+ times faster here). HTH.

---
kai

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: how to make/move a new window underneath the other windows
  • Next by Date: Re: alias from Finder file object
  • Previous by thread: Re: Networking / AS query
  • Next by thread: itunes and duplicating track from library
  • Index(es):
    • Date
    • Thread