• 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: Search Folder Hierarchy
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Search Folder Hierarchy


  • Subject: Re: Search Folder Hierarchy
  • From: Adam Bell <email@hidden>
  • Date: Sat, 28 Jan 2006 15:52:37 -0400

I like this one (modified from various bits and pieces found elsewhere)

-- This script is faster than any equivalent in the Finder for indexing a folder's contents when it contains nested folders.
set theFldr to choose folder with prompt "Select a folder to index:"
set allFiles to (do shell script "ls -R " & quoted form of POSIX path of theFldr)
-- to get this in another script, just use the first two lines.
-- The rest opens a file in which to save the index gives it
-- the base name of the folder and saves the list.
set FldrName to "Idx_" & basename(theFldr) & "_" & (do shell script "date \"+%y-%m-%d\"") & ".txt"
set theFile to choose file name with prompt "Save the Index as:" default name FldrName

try
    set F to open for access theFile with write permission
    write allFiles to F
    close access F
on error e
    try
        close access F
    end try
    display dialog e buttons {"Cancel", "OK"} default button 2 with icon 2
end try

on basename(thePath)
    set astid to AppleScript's text item delimiters
    set AppleScript's text item delimiters to (last character of (thePath as text))
    set thePath to text item -2 of (thePath as text)
    set AppleScript's text item delimiters to astid
    return thePath
end basename


On 1/28/06, Martin Orpen <email@hidden> wrote:
On 28 Jan 2006, at 6:55 pm, has wrote:

> Save as applet:
>
>    on open {f}
>       tell application "Finder" to set lst to name of every file in
> entire contents of container f
>       set text item delimiters to return
>       tell application "TextEdit" to make new document with
> properties {text:lst as Unicode text}
>    end open
>
> This approach'll suck performance-wise if there's a very large
> number of files, however. If this is an issue, consider using the
> unix shell instead, e.g. something like:
>
>    ls -R /path/to/sourcefolder | egrep '^[^/]+$' | sort -f > /path/
> to/outputfile.txt
>
> would produce a UTF8-encoded text file containing a nicely sorted
> [1] list of linefeed-delimited filenames.


Alternatively, you can just drag a folder onto an open BBEdit or
TextWrangler document.

I''ve always loved that feature. Easy, and fast. And free if you use
TextWrangler.

Regards

--
Martin Orpen


_______________________________________________
Do not post admin requests to the list. They will be ignored.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: Search Folder Hierarchy (From: Martin Orpen <email@hidden>)

  • Prev by Date: Re: Entourage Scripting Question
  • Next by Date: Re: Search Folder Hierarchy
  • Previous by thread: Re: Search Folder Hierarchy
  • Next by thread: Re: Search Folder Hierarchy
  • Index(es):
    • Date
    • Thread