• 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: Christopher Stone <email@hidden>
  • Date: Thu, 24 Jul 2014 03:26:50 -0500

On Jul 23, 2014, at 15:59, Jan E. Schotsman <email@hidden> wrote:
You're right, this works too.
Something mysterious is going on here.
If I omit "path of" in line 4 of your code it fails.
______________________________________________________________________

Hey Jan,

Nothing mysterious.

set myMoviesList to path of files of myMoviesfolder

This line of code is in a System Events tell block and produces a System Events reference somewhat similar to a Finder reference.

-------------------------------------------------------------------------------------------
set testFolder to alias ((path to movies folder as text) & "Test Folder:")
tell application "System Events"
set movieFile to first file of testFolder whose visible is true and kind is "MPEG-4 movie"
end tell

--> file "Ryoko:Users:chris:Movies:Test Folder:Hegre-Art_Trailer.mp4" of application "System Events"
-------------------------------------------------------------------------------------------

This result is not a pure file reference but is of application "System Events", so it's not very surprising it won't function outside the System Events context.

The path to specifier returns plain-text HFS paths, and these are easily coerced to other forms outside of the SEV context.

Moving back to Posix files:

-------------------------------------------------------------------------------------------
set testFolder to alias ((path to movies folder as text) & "Test Folder:")
tell application "System Events"
set movieFileList to path of files of testFolder whose visible is true and kind is "MPEG-4 movie"
end tell
repeat with i in movieFileList
set contents of i to POSIX file (POSIX path of (get contents of i))
end repeat
movieFileList
-------------------------------------------------------------------------------------------

I like to reuse lists when doing file format conversions unless I need the original for some reason.  It's fast, the code is clean, and in long lists there is less memory usage.

--
Best Regards,
Chris

 _______________________________________________
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>)

  • Prev by Date: Re: file list as data
  • Next by Date: Re: file list as data
  • Previous by thread: Re: file list as data
  • Next by thread: Encrypt/Decrypt a Text File
  • Index(es):
    • Date
    • Thread