• 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: List content of a folder, output to document
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: List content of a folder, output to document


  • Subject: Re: List content of a folder, output to document
  • From: Luther Fuller <email@hidden>
  • Date: Wed, 06 Jan 2010 11:41:48 -0600

On Jan 5, 2010, at 4:37 PM, Inge Eidem wrote:

Can you help me?
I need to get a folder´s content/items to be listed in a file for archiving.

I just remembered that I had a script that did something like that. After a little hunting, I found it.
Compile this ...

property indent : ".    "

on run
try
my getFinderSelection()
if the result ≠ {} then my printSelection(the result)
on error errText number errNr
"Error = " & errNr & return & errText
display dialog the result buttons {"OK"} default button 1
end try
end run ---------------------------------

on printSelection(selItems)
tell application "Finder"
set contentsText to ((container of some item of selItems) as text) & return & return
repeat with selItem in selItems
if (class of item selItem) is folder then
my printFolder(selItem, "")
else
"" & (name of selItem) & return
end if
set contentsText to contentsText & the result
end repeat
end tell
tell application "TextEdit"
activate
set NewDoc to make new document
set text of NewDoc to contentsText
end tell
end printSelection -------------------

on printFolder(folderAlias, prefix)
tell application "Finder"
set folderText to prefix & (name of folderAlias as text) & ":" & return
if (count items of folderAlias) = 1 then
set itemList to {(some item of folderAlias) as alias}
else
set itemList to (items of folderAlias) as alias list
end if
repeat with theItem in itemList
if (class of item theItem) is folder then
my printFolder(theItem, prefix & indent)
else
prefix & indent & (name of theItem) & return
end if
set folderText to folderText & the result
end repeat
end tell
return folderText
end printFolder ------------------------------------

on getFinderSelection()
tell application "Finder"
try
set selList to selection
on error
return {}
end try
--
set listCount to (count items of selList)
if listCount = 0 then return {}
repeat with i from 1 to listCount
(item i of selList) as alias
set item i of selList to the result
end repeat
return selList
end tell
end getFinderSelection ---------------------------------------

 _______________________________________________
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

References: 
 >List content of a folder, output to document (From: Inge Eidem <email@hidden>)

  • Prev by Date: Re: List content of a folder, output to document
  • Next by Date: Re: Use AS operators dinamically
  • Previous by thread: Re: List content of a folder, output to document
  • Next by thread: RE: List content of a folder, output to document
  • Index(es):
    • Date
    • Thread