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
|