Re: Find out in which subfolder a given file resides
Re: Find out in which subfolder a given file resides
- Subject: Re: Find out in which subfolder a given file resides
- From: "Stockly, Ed" <email@hidden>
- Date: Tue, 13 Oct 2015 20:27:20 +0000
- Thread-topic: Find out in which subfolder a given file resides
This is actually the one context where "entire contents" seems to work:
--------
set rootDirectory to alias "TVTimes:2010 TV Times
Production:Done:06-27-10-TV Times:latpages.sit Folder:"
set fileName to "6-27-10-TV Times.indd"
tell application "Finder"
set myFiles to every file of entire contents of rootDirectory as alias
list
end tell
--then step through that list to find your file
--or
tell application "Finder"
set myFiles to (first file of entire contents of rootDirectory whose
name is fileName) as alias
end tell
————
The caveat is that if your directory contains thousands (hundreds?) of
folders the entire contents command will choke your Finder to death and
you'll need to relaunch it.
>
>I am working on a script that tells InDesign CS6 (on OS 10.10.5) to
>auto-layout folder pages. I’m almost ready with the script, except for
>the part where I need to place images from a folder called
>“Highres_Images”. This folder contains many subfolders and is on a
>mounted server volume. At some given moment when the script runs I have a
>variable that contains just the name of a certain image, for example: set
>myImage to “picture123.jpg”. To be able to place this image on an
>InDesign page I need the full HFS path of the image.
>The image “picture123.jpg” is somewhere inside the “Highres_Images"
>folder. This folder contains many, many subfolders, which contain
>subfolders, etc, etc, several levels deep. I don’t know in which
>subfolder the image is.
>
>I was thinking of 2 approaches, still need to find out which one works
>best:
>1. I could get a list of all subfolders (HFS paths, not just names) and
>then loop through the list and find out in which folder the image is
>(with a Finder statement if exists). If the file exist I know its path
>and I can exit the loop.
>2. I could get a string of all files (HFS paths, not just names) that are
>inside the Highres_Images folder. Then I could use the filename as a text
>delimiter and split the string in parts, etc, etc, to find out in which
>subfolder the file is.
>
>I‘m afraid I really need some “do shell script” stuff to fix this quickly
>(fast execution time I mean). Unfortunately I have little or no knowledge
>about this, so I hope someone can help. For example a "do shell script"
>on how to build a text string with HFS paths of all images inside the
>Highres_Images folder, including files that are in subfolders.
>
>ps. I’m absolutely sure there are only jpg and some psd files inside the
>folder, so there shuldn’t be a problem with invisible files, packages,
>etc.
>
>Thanks in advance for any help,
>Bert.
>
>
>
> _______________________________________________
>Do not post admin requests to the list. They will be ignored.
>AppleScript-Users mailing list (email@hidden)
>Help/Unsubscribe/Update your Subscription:
>imes.com
>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