• 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: file list as data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: file list as data


  • Subject: Re: file list as data
  • From: Emmanuel LEVY <email@hidden>
  • Date: Thu, 24 Jul 2014 14:25:29 +0200

Those who can use Satimage.osax will find the following entry in its dictionary:

glob v : list the files or the folders matching a unix pathname pattern
glob string or list of string : the pattern
[from alias] : the working directory. By default, the direct parameter must be a full posix path pattern
[invisibles boolean] : default: false
[of extension list of string] : the required file extension(s)
[not conforming to list of string] : the forbidden Universal Type Identifier(s) (UTI)
[after date] : list only items whose modification date is after the after date parameter
[before date] : list only items whose modification date is before the before date parameter
[names only boolean] : default: false
[as type] : string (URL), alias, unix path, path...
→ list of string or list of alias

Emmanuel

On Jul 24, 2014, at 1:58 PM, Shane Stanley wrote:

> On 24 Jul 2014, at 7:12 pm, Christopher Stone <email@hidden> wrote:
>
>> I believe Shane's library here can be adapted to do the deed:
>>
>> http://lists.apple.com/archives/applescript-users/2014/Jul/msg00012.html
>
> No, that's not recursive. And it's probably not the most efficient way to filter by extension.
>>
>> I thought he'd posted one to specifically return a recursive directory tree, but I can't seem to find it at the moment.
>
> He hadn't, but this will do the job:
>
> on searchDirectory:folderPOSIXPath forExtensions:extensionList
> 	-- make NSString of folder path
> 	set folderPathNSString to current application's NSString's stringWithString:folderPOSIXPath
> 	-- get file manager
> 	set fileManager to current application's NSFileManager's defaultManager()
> 	-- ask file manager for all subpaths recursively
> 	set theFileNSArray to fileManager's subpathsOfDirectoryAtPath:folderPOSIXPath |error|:(missing value)
> 	-- filter the array according to extension
> 	set theFileList to (theFileNSArray's pathsMatchingExtensions:extensionList) as list
> 	-- combine subpaths and folder path to get full paths
> 	set finalList to {}
> 	repeat with aSubpath in theFileList
> 		set end of finalList to (folderPathNSString's stringByAppendingPathComponent:aSubpath) as text
> 	end repeat
> 	return finalList
> end searchDirectory:forExtensions:
>
> So:
>
> set folderPOSIXPath to POSIX path of (path to desktop)
> tell script "<lib name>" to set thePaths to its searchDirectory:folderPOSIXPath forExtensions:{"asobjcex3doc"}
>
> Using find is a whisker faster in my simple tests.
>
> --
> Shane Stanley <email@hidden>
> <www.macosxautomation.com/applescript/apps/>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> Archives: http://lists.apple.com/archives/applescript-users
>
> This email sent to email@hidden


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden


References: 
 >Re: file list as data (From: "Jan E. Schotsman" <email@hidden>)
 >Re: file list as data (From: Bruce Robertson <email@hidden>)
 >Re: file list as data (From: Christopher Stone <email@hidden>)
 >Re: file list as data (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: codesigning results in "app is damaged" error
  • Next by Date: save and close window
  • Previous by thread: Re: file list as data
  • Next by thread: Re: file list as data
  • Index(es):
    • Date
    • Thread