• 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: Selecting a file by type and creation date
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Selecting a file by type and creation date


  • Subject: Re: Selecting a file by type and creation date
  • From: Axel Luttgens <email@hidden>
  • Date: Sat, 23 Apr 2011 11:48:05 +0200

Le 22 avr. 2011 à 20:11, Paul Murphy a écrit :

> Hello,
>
> I know this is probably a very basic question...
>
> I have a folder which contains a series of sub-folders, inside each sub-folder is a series of files of different file types.  I'd like to get the POSIX path of most recently created JPEG in the most recently created subfolder.
>
> Any help greatly appreciated!

Hello Paul,

Possibly not that basic, after all... ;-)

Assuming your folder structure is one-level deep and file extensions are sufficient to locate any file of interest, this could be of some help:

	on MostRecent(FolderPath, Xtension)
		local SubFolders
		tell application "System Events" to set SubFolders to path of (folders of folder FolderPath whose ((files whose name extension is Xtension) is not {}))
		if SubFolders is {} then return missing value
		tell application "Finder" to get (item 1 of (sort (files of item 1 of (sort SubFolders by creation date) whose name extension is Xtension) by creation date)) as alias
		return POSIX path of result
	end MostRecent

The idea is: first fetch all candidate sub-folders (the ones containing at least one file of interest), then get the most recently created folder amongst those folders, then get the most recently created file of interest in that folder.

For example, I get here:

	MostRecent("/Library/", "app")
	--> "/Library/Parallels/Parallels Transporter.app/"

Of course, depending on your workflow, this may prove extremely costly...

HTH,
Axel

 _______________________________________________
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: 
 >Selecting a file by type and creation date (From: Paul Murphy <email@hidden>)

  • Prev by Date: Re: Selecting a file by type and creation date
  • Next by Date: Trigger 'Gather Windows'
  • Previous by thread: Re: Selecting a file by type and creation date
  • Next by thread: Trigger 'Gather Windows'
  • Index(es):
    • Date
    • Thread