(every document file of every folder in folder thePath) as alias list

On Dec 9, 2006, at 1:03 AM, Bill Hernandez wrote:
I use "set aList to get every file of every folder in startFolder" the references are to "document file path2file" instead of "alias to path2file", and I was not successful getting BBEdit to work with them without generating errors
On Dec 9, 2006, at 9:25 AM, Jim Correia wrote:
The open event requires a list of file references (aliases). This is true of all scriptable applications, not just BBEdit.
Normally you can coerce Finder object references to aliases. In this case a bug in the Finder is getting in your way.
set aList to get every file of every folder in startFolder
This is returning invalid object references - ones not even the Finder can resolve at a later date.
It seems to drop one level of hierarchy when building the object specifiers in response to that whose clause. You can avoid the Finder bug by using some alternate means of building up the file list.
Jim
Here's what I came up with, and it solved my problem...
-- ---------+---------+---------+---------+---------+---------
on script_title()
Filename : getevery_file_ofevery.scpt (Script Debugger)
Author : Bill Hernandez
Version : 1.0.0
Updated : Tuesday, January 02, 2007 ( 6:15 PM )
end script_title
-- ---------+---------+---------+---------+---------+---------
on script_notes( )
This is a work around to the alias list problem I encountered
end script_notes
-- ---------+---------+---------+---------+---------+---------
tell application "Finder"
activate
set thePath to choose folder
-- THIS DOES NOT GIVE THE CORRECT ANSWER --> instead of an alias list, it returns a document list
set aSel to (((every document file in folder thePath) & (every document file of every folder in folder thePath)) as alias list)
display dialog ("[2451] " & (get modification date of (item 1 of aSel)) as string)
set f_info to info for (alias ((item 1 of aSel) as text))
display dialog ("[2452] " & (get modification date of f_info) as string)
-- THIS DOES THE TRICK, it returns an alias list
set aSelection1 to (every document file in folder thePath) as alias list
set aSelection2 to ((every document file of every folder in folder thePath)) as alias list
set aSelection to (aSelection1 & aSelection2)
display dialog ("[2453] " & (get modification date of (item 1 of aSelection)) as string)
set f_info to info for (alias ((item 1 of aSelection) as text))
display dialog ("[2454] " & (get modification date of f_info) as string)
end tell
-- ---------+---------+---------+---------+---------+---------

Hi Bill,
That's not really a bug. In this line:
set aSel to (((every document file in folder thePath) & (every document file of every folder in folder thePath)) as alias list)
two list are being concatenated which returns a list and 'as alias list' doesn't work on lists. You could do this:
set aSel to (every document file in folder thePath as alias list) & (every document file of every folder in folder thePath as alias list)
If there aren't anymore levels, then you can use 'entire contents':
every document file of entire contents of folder thePath as alias list
Note that if only one file is returned, then it will error because of automatic coercion, so it's better to do it your way if you don't know how many files there are. Then, you would use an error handler to trap the error. Here's what I've been using:
try
set aSel1 to (every document file in folder thePath as alias list)
on error from o
set aSel1 to o as list
end try
try
set aSel2 to (every document file of every folder in folder thePath as alias list)
on error from o
set aSel2 to o as list
end try
set aSel to aSel1 & aSel2
There is another way to coerce finder references to something usable in other applications that can't deal with Finder references. You can coerce Finder references to strings using text item delimiters.
gl,

Similar Messages

  • Listing folder contents as alias list

    the list folder command returns a list of filenames,
    however I need something that returns a list of full fledged file references.
    This:
    [set foldercontents to contens of (choose folder)]
    works by returning a list of document files with full paths. It does seem like an alias list:
    get every document file of alias "HD:temp:"
    {"HD:temp:file1", "HD:temp:file2","HD:temp:file3"}
    But when I try to use it to concatenate another alias list, such as
    set mylist to {}
    repeat with ct from 1 to count of items in foldercontents
    if (something)
    set mylist to mylist & item ct of foldercontents
    end if
    end repeat
    the result is
    get document file "file1" of folder "temp" of startup disk
    "Finder got an error: Unknown object type."
    why?
    and how can this be circumvented?
    TIA
    Asu

    01. At least, on my MacOS X 10.4.4 based PowerMac ...
    tell application "Finder" to set my_List to contents of (choose folder)
    ,,, results with an alias path of the selected folder; not a list of the folder's contents. If possible, I will try the above code on other Macs.
    02. The following code ...
    set source_Folder to (path to desktop folder from user domain)
    tell application "Finder" to set my_List to every item of folder source_Folder
    ... or ...
    tell application "Finder" to set my_List to every item of (choose folder)
    ... will produce a list of all items in the selected folder. In a 'document file [or 'folder'] "..." of folder "..." of folder "..." ... of application "Finder"' format.
    03. For a list of the 'alias "..."' format, use either ...
    set nList to {}
    tell application "Finder" to set my_List to every item of (choose folder)
    repeat with i in my_List
    copy (i as alias) to end of nList
    end repeat
    my_List & return & return & "----------------" & return & return & nList
    ... or ...
    tell application "Finder" to set my_List to every item of (choose folder)
    repeat with i from 1 to (count my_List)
    set (item i of my_List) to ((item i of my_List) as alias)
    end repeat
    my_List
    ... For only 'file's use ...
    tell application "Finder" to set my_List to every file of (choose folder)
    repeat with i from 1 to (count my_List)
    set (item i of my_List) to ((item i of my_List) as alias)
    end repeat
    my_List
    04. To concatenate two (2) lists (of every item) ...
    tell application "Finder" to set folder01 to every item of (choose folder)
    tell application "Finder" to set folder02 to every item of (choose folder)
    set new_List to {}
    repeat with i from 1 to (count folder01)
    copy ((item i of folder01) as alias) to end of new_List
    end repeat
    repeat with i from 1 to (count folder02)
    copy ((item i of folder02) as alias) to end of new_List
    end repeat
    folder01 & return & return & "----------------" & return & return & folder02 & return & return & "----------------" & return & return & new_List
    05. To concatenate two (2) lists (of every file) ...
    tell application "Finder" to set folder01 to every file of (choose folder)
    tell application "Finder" to set folder02 to every file of (choose folder)
    set new_List to {}
    repeat with i from 1 to (count folder01)
    copy ((item i of folder01) as alias) to end of new_List
    end repeat
    repeat with i from 1 to (count folder02)
    copy ((item i of folder02) as alias) to end of new_List
    end repeat
    folder01 & return & return & "----------------" & return & return & folder02 & return & return & "----------------" & return & return & new_List
      Mac OS X (10.4.4)  

  • Finder got an error: Can't get item 1 of {document file "foo" ...}

    I have a lot of files in Corel Painter 8's RIFF format. I want to write a script that opens a file and somehow forces Corel Painter 8 to save the file as a GIF. GUI scripting may be some help with the latter; now I am concentrating on finding RIFF files and opening them in Corel Painter 8.
    I have a script that does a depth-first search of the folders starting at some root folder, using the Finder application to do the file-system stuff. It creates a list with
    set docs to every document file of pages_folder whose file type = "RIFF"
    as it loops through folders it adds to the list like this:
    set more_documents to every document file of a_folder whose file type = "RIFF"
    set docs to docs & more_documents
    My naîve mental model is that docs is a list of document-file objects. Next I have a loop that attempts to strip out files for which a GIF file already exists (and is no older than the RIFF document). This works by deleting non-matching items like so:
    if not isgifneeded then
    set docs to items 1 thru (i - 1) of docs & items (i + 1) thru (length of docs) of docs
    end if
    Finally it tries to open one of the files in Corel Painter 8 using the Finder:
    open item 1 of docs using "Corel Painter 8"
    This does not work. I get an error message
    Finder got an error: Can't get item 1 of {document file "bar" of folder "foo" of folder "blah" of folder "pdc" of folder "Users" of startup disk, ... }."
    It lists all of the files. (The error message appears in a sheet that extends off the bottom of the screen!) They are identified in the message as document-file objects. The curly braces are, I believe, the AppleScript notation for a list. I expect to be able to obtain the first element of a list with ‘item 1 of xs’. My assumption is that the Finder’s open command would expect a document file object, or at least would be able to cope with being asked to open a document. What am I missing here?
    PowerBook 12" without mini-DVI   Mac OS X (10.4.7)  

    Hi Damian and welcome to Apple Discussions!
    One suggestion: try
    tell application "Finder" to open item 1 of docs
    (without 'using "Corel Painter 8"')
    As far as the Finder is concerned, "Corel Painter 8" is just a string of characters. And telling the Finder to open a file is just the same as double-clicking it: the Finder knows which app to use - as long as these are native Corel Painter 8 docs.
    Hope this helps,
    H

  • Automate Batch, open every 3 files in a folder?

    I'm doing some work where I mostly do the same things on three files. It's for a game-project and I've got one texture for shadows, one that's the normal diffuse layer and finally one that controls where team-colors go. I've learnt some things about the Actions-tab and can easily open all three files then click F2 and Photosohp CS4 does all the work. Then I simply save the file.
    I was checking with the the Automate -> Batch option if I could do this for an entire folder but I've ran out of luck. It's easy enough with the destination, I just add a prefix to the file-name so it doesn't overwrite anything. However as I see it it's only possible to open every file in the folder after each-other. Is there a built-in feature or can I change the Actions a little to help me with this? The Actions I'm doing is mostly "Select Previous Document" etc. when I've got all three files open.
    Failing in that is there a plugin or something anyone can recommend? If it helps the file-names are identical except for a "_diffuse", "_occulusion" and "_team" at the end so if there's a plugin or even feature that relies on the file-names that would work too. Otherwise this also means the three files are always after each-other in the same order.

    You should look into Scripting for Photoshop (preferably with JavaScript), because what you are describing is not within reach for plain Actions as they can incorporate no conditionals.
    »Adobe Intro To Scripting.pdf«, »Photoshop CS5 Scripting Guide.pdf« and the Sample Scripts (should all have been installed with Photoshop) offer a starting point and one can always ask for advice on the Photoshop Scripting Forum:
    Photoshop Scripting
    What exactly are the automated steps for the three different »types« of images?

  • Script to take every 5th file from a folder and copy it to another folder

    How can I tell applescript to take every 5th file of a folder of say 2000 files and copy them to another location? I want to copy the 5th, 10, 15th, 20th files and so on of 2000 files so I will have only 400 files.
    I guess I want to make a list of all the files and then coerce that to the first and then increments of five but how do I do that?
    Thanks.
    Pedro

    Hi Pedro,
    The following script should do what you are asking for:
    *set theSourceFolder to choose folder with prompt "Select the source folder."*
    *set theTargetFolder to choose folder with prompt "Select the target folder."*
    *tell application "Finder"*
    *set theFiles to files of theSourceFolder*
    *repeat with k from 5 to (count theFiles) by 5*
    *move item k of theFiles to folder theTargetFolder*
    *end repeat*
    *end tell*
    Message was edited by: Pierre L.

  • How can I do the same as Windows Explorer with datemodified:11/6/2013 .. 11/13/2013 showing only changed files with path in tree and NOT every folder along the way as Finder seems to do by default? Thanks!

    I'm an Apple newbie.
    I'd like to be able to list each file in the "Desktop" tree (ie; on the desktop, or in any folder on the desktop, etc.), along with its path, that has been modified since a certain date.
    When I use Finder to do a similar search, I get tons of output including every folder in the path to the modified file, etc. Although I can view the path to the individual files in the output, I can't for example, order the output by path, etc.  Very difficult to sort through. I'd love to have output like the example above - just the filename and path for each changed file.  Possible?  Thanks in advance!
    Wayne

    The file structure is a little complex. I will use inbox as an example.
    Inbox (a large file with no file extension)
    Inbox.msf ( An index of inbox with tags etc. Can be deleted with only loss of tags)
    Inbox.sdb (a folder, indicating that the folder within Thunderbird has a sub folder.
    POP mail is stored in
    Appdata/Roaming/Thunderbird/Profiles/*.default/Mail/[Server name]/
    Local folder is stored in
    Appdata/Roaming/Thunderbird/Profiles/*.default/Mail/Local Folders/
    As long as you do not overwrite, you can copy and paste whole folder trees into local folders (stuff on your old computer under a mail account is best relocated to local folder and then sorted as necessary afterwards.
    Note that you should delete foldertree.json after making those sorts of copies (it forces a full refresh of the folder tree, no cache) and under no circumstances copy data with Thunderbird running. It can irrevocably corrupt things

  • How to do a FFT tranformation for every file in a folder of another folder?

    Dear all,
    I have a folder A, there are seven folders in folder A, I call these seven folders B. and there are 100 files in every folder B. These files are all the data information of current.
    ok, now I need to transfer every current file into a FFT tranformation, and save the transferred files corresponding to the original file.
    Does anyone have some idea? Thank you for any help!
    Jing

    Hi Mike
    In this way, How can I save the transferred files as the same way as the original files and folders?
    after FFT transformation, I hope to get 100 files in every "transferred B" and seven "transferred B" folders in one "transferred A" folder.
    Jing 

  • HT1347 When I add a folder to the library, does that mean that 'later' when I drop a new file into that folder (already added) it will automatically end up in iTunes? (or do I have to add file/folder to library every time I have a new file??) I'm using XP

    When I add a folder to the library, does that mean that 'later' when I drop a new file into that folder (already added) it will automatically end up in iTunes? (or do I have to add file/folder to library every time I have a new file??) I'm using XP...

    iTunes does not actively scan the media folders.  If you manually add content to a folder, then you must add that content to iTunes manually via the File > Add File/Folder feature.
    The only folder that gets scanned is the "Automatically add to iTunes" folder.

  • When I open a folder then open a document in the folder every time i close the document it closes the folder where is the back button ?

    When I open a folder on my mac pro retina osx 10.9.1 then a document every time I close the document it closes the folder where is the back button?

    Try COMMAND-[.
    Ciao.

  • Does anyone has the same scrolling problem? My macbook air 13''(2010) running lion, when files in a folder arranged by kind, every scrolling paused for a second..?

    does anyone has the same scrolling problem? My macbook air 13''(2010) running lion, when files in a folder arranged by kind, every scrolling paused for a second..?

    does anyone has the same scrolling problem? My macbook air 13''(2010) running lion, when files in a folder arranged by kind, every scrolling paused for a second..?

  • Batch file for checking every folder

    hello friends,
    i have query  in creating batch programming.
    i have lot of folders in my local drive.
    i want to create a log file in every folder but log file is already available in some folders.
    i need a program that follow bellow steps.
    1. check the folder1 if log file is not available means to create the new log file and go to the next folder for same.
    2. if available means go to next folder check the same.
    the program check one by one folder based  on above condition.

    function Recurse-Folders([string]$path) {
    $LogFile="Log.txt"
    Set-Location -Path $Path
    $L=Get-Location
    IF (Test-Path -path $Logfile)
    Write-Host "Log File Exists in "+$L.Path
    ELSE
    Write-Host "Creating Log File in "+$L.Path
    Add-Content $LogFile "Log File Contents"
    [String[]]$Folders = Get-ChildItem "." -Directory
    ForEach ($F in $Folders)
    Recurse-Folders($F)
    Set-Location -Path ".."
    CD C:
    CD \
    MD \Test
    MD \Test\Test1
    MD \Test\Test1\Folder1
    MD \Test\Test1\Folder2
    MD \Test\Test1\Folder3
    MD \Test\Test1\Folder4
    MD \Test\Test1\Folder1\SubFolder1
    MD \Test\Test1\Folder1\SubFolder2
    MD \Test\Test1\Folder3\SubFolder1
    MD \Test\Test1\Folder3\SubFolder2
    MD \Test\Test2
    MD \Test\Test2\Folder1
    MD \Test\Test2\Folder2
    MD \Test\Test3
    MD \Test\Test3\Folder1
    MD \Test\Test3\Folder2
    Recurse-Folders("Test")

  • I have an iMac with OS x 10.8.  Every folder t hat opens has (in the gray zone on top) file icons and jpg photos listed.  How do I remove them?

    I have an iMac with OS x 10.8.  Every folder t hat opens has (in the gray zone on top) file icons and jpg photos listed.  How do I remove them?

    Control-click each and choose Remove Item, or Command-click them and drag them out.
    (85250)

  • Desktop files automatically replicated  in every folder

    My desktop files are automatically being saved in every desktop folder. When I empty them from a folder into the Trash, the file also disappears from the desktop. I ran a virus scan, but not a virus that the scan could detect.
    Thoughts?

    Now every folder on the desktop contains every item on the desktop.
    That's an obvious impossibility, so I'd have to assume that you're misunderstanding something.  Can you post a screenshot or two to show us what you're seeing?

  • Publish site changes edits every folder in "entries" directory

    I utilize Lytebox slideshows in my blog entries and have an issue with MobileMe erasing the necessary Lytebox files from every blog Entries directory (Web/Sites/Site Name/Site Name/Entires/Year/Month).
    I always update my website via Files>Publish Site Changes. I publish to MobileMe so that I can make my site private.
    I expect MobileMe to overwrite the files in the Entries folder for the specific blog entry I have created/changed, but why are the Lytebox files erased from every single Entries folder? I just did a test by making a minor change to a blog entry, publishing site changes and then using Cyberduck to check the Entries directory. Sure enough, every folder in that directory was modified.
    As a result, every time I make any changes to my website, I have to upload the Lytebox files to every Entries folder, currently I have 15 of them.
    Any reason MobileMe is doing this? Can I avoid this from happening? If not, I'll post another question about how to quickly and automatically upload the lytebox files to every Entries folder.
    Thank you.

    Any 3rd party files/folders used for java based slideshows in an iWeb site should be placed in the iDisk/Web/Sites folder and linked to there and NOT in the site's folder itself for the very reason you're experiencing. That is, they get deleted when the site is republished. It's the nature of iWeb.
    You should use the following URL to link to a particular file in the Lytebox folder (assuming that folder is named Lytebox): http://web.me.com/MobileMeAccount_Name/Lytebox/Filename.
    OT

  • What is changing the modification date of every folder?

    Almost every folder and subfolder on my hard drive has the same modification date and time but they were not actually modified. The modification dates on individual files within are still unique. I looked around in the logs for some event at the date and time but couldn't find anything. What could cause this?

    Hi,
    take a look at LogMiner
    regards
    vlado

Maybe you are looking for

  • Opening PDFs in Indesgin?

    A supplier of mine has sent me a pdf version of some artwork that was originally a .indd file.  Is there any way (like with Illy) that I can open the PDF in InDesign (or Illy) and edit it? OS - Windows XP InDesign - CS Version 3.0 Thanks Sarah

  • Restriction of Activiate PR in CN22

    Hi, I have created one Network through CN21 and assigned user status also. My user status is BURQ - Budget Approval Request. I have restricted business transactions like Material purchase requisition & PO for this status. My system status of the netw

  • Migrating SQL Server 7.0 to Oracle 8i in Different Operating Systems

    I am migrating SQL Server 7.0 Databases on NT to Oracle 8i on Sun 2.6. Is there is any other way other then Migration Workbench. If Mig Workbench is OK. What are the steps to do Migration. null

  • RFC Structure Reference in V12

    We had a custom RFC developed to perform a read on a Z_Table.  The ABAP developer unfortunately used a complex deep structure that could not be used with the JCO connector. We have had the problem with the RFC fixed, but xMII has retained the origina

  • Source of the stuttering playback in CC 2014

    I'm trying to playback a series of 4K tiff images and it's probably only playing about 1/4 of the frames, if that. I know that's a tough ask of any computer, but when I saw how the hardware was working I thought I'd check I haven't done anything wron