Skip to main content
klemango
Inspiring
February 22, 2013
Answered

Shell Search

  • February 22, 2013
  • 1 reply
  • 1140 views

Hello Everyone,

Currently I'm using this to get a list of files from a folder:

var artPath = Folder ("A:/NITTANY/COMPLETED");

var allFiles = artPath.getFiles();

The user then enters the work-order number, and the list of files is looped through to find a match.  The file is then opened in AI.  Works, but it's slow because there's over 500-1000 files in this folder at any given time.  Before we went to PC's and were still on the Macs, I had written this code in Applescript to speed things up a bit:

set files_found to paragraphs of (do shell script "find" & quoted form of posix_path & "-type f -name" & Die_num)   (where posix_path is the folder path and Die_num is the user input(filename to search for).

Is there any way to incorporate this into the Javascript code above?   Or is that kind of file access considered taboo?

Thanks again for all your help!

This topic has been closed for replies.
Correct answer CarlosCanto

getFiles() takes an optional argument [mask], where mask is a search string that supports all usual wildcards, so to search for order 1234

var order = '*1234*';

var artPath = Folder ("A:/NITTANY/COMPLETED");

var allFiles = artPath.getFiles(order);

1 reply

Inspiring
February 22, 2013

Bridge and Photoshop can call the command line using app.system() Indesign can app.doScript() and have AppleScript call the shell… AI can do nothing… I would have thought < 1k files would not be too slow…

klemango
klemangoAuthor
Inspiring
February 22, 2013

Thanks, Mark!

It's really not too slow, and it's probably not even an issue with the users.  I put that line in the applescript b/c at the time we where on very early G4 machines and it did make a difference on those. 

I happened to notice a little bit of latency when the number of files grows (sometimes, during busy season the file count can be close to 2,000) and I was just wondering if there was a way to call the command line.  Just looking for something to do, I guess.

CarlosCanto
Community Expert
CarlosCantoCommunity ExpertCorrect answer
Community Expert
February 22, 2013

getFiles() takes an optional argument [mask], where mask is a search string that supports all usual wildcards, so to search for order 1234

var order = '*1234*';

var artPath = Folder ("A:/NITTANY/COMPLETED");

var allFiles = artPath.getFiles(order);