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 ---------------------------------------