• 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: Index a given folder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Index a given folder


  • Subject: Re: Index a given folder
  • From: "Stockly, Ed" <email@hidden>
  • Date: Wed, 7 Apr 2010 18:47:41 -0500
  • Acceptlanguage: en-US
  • Thread-topic: Index a given folder

> 1.  be pointed to a chosen folder,
>
> 2.  will get the names of every file in that folder,
>
> 3.  generate a text file which lists all the files in that folder
> (order doesn't really matter, but alphabetical would be nice), and
>
> 4.  save the text file to Desktop.

Try this:
HTH
ES

set myFolder to choose folder
open {myFolder}

on open folderList
    repeat with thisFolder in folderList
        set folderPath to thisFolder as text
        if the last character of folderPath is ":" then
            tell application "System Events"
                set folderName to name of thisFolder
                set fileName to "item names from " & folderName & ".txt"
                set newFile to folderPath & fileName
                set itemNames to the name of every item of thisFolder as
list
            end tell
            set AppleScript's text item delimiters to {return}
            set fileText to itemNames as text
            my OpenWriteClose(newFile, fileText)
        end if
    end repeat
end open

on OpenWriteClose(myFile, myText)
    try
        set openFile to (open for access myFile with write permission)
    on error
        close access openFile
        set openFile to (open for access myFile with write permission)
    end try
    set eof of openFile to 0
    write myText to openFile
    close access openFile
end OpenWriteClose

 _______________________________________________
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

  • Follow-Ups:
    • Re: Index a given folder
      • From: Jason Donnelly <email@hidden>
    • Re: Index a given folder
      • From: Doug McNutt <email@hidden>
References: 
 >Index a given folder (From: Jason Donnelly <email@hidden>)

  • Prev by Date: pList read and write
  • Next by Date: Re: Index a given folder
  • Previous by thread: Re: Index a given folder
  • Next by thread: Re: Index a given folder
  • Index(es):
    • Date
    • Thread