Re: Formatting text returned from shell script
Re: Formatting text returned from shell script
- Subject: Re: Formatting text returned from shell script
- From: Emmanuel <email@hidden>
- Date: Wed, 19 Mar 2003 08:58:25 +0100
At 12:54 AM +0000 19/03/03, Mr Tea wrote:
set theName to name of (info for theFolder)
I would suggest not to call "info for" when you need only the name.
"info for" computes the size of the folder. For the name, I would
rather ask Finder or play with tid's.
Emmanuel
set thepath to quoted form of POSIX path of theFolder
set currentIndex to theFolder as string
do shell script "ls -R " & thepath returning theDir
set theDirList to every paragraph of theDir
set newList to {"Contents of folder \"" & theName & "\"" & return &
thepath & return & return}
set theFilePrefix to ""
repeat with i from 1 to count of theDirList
set theLine to item i of theDirList
set my text item delimiters to "/"
set theMarker to count of text items of thepath
set theCount to count of text items of theLine
set currentFolder to text item -1 of theLine
set theFolderPrefix to ""
if theCount is greater than theMarker then
set theNestIndex to theCount - theMarker
set theTally to -1
set theFilePrefix to ""
set theSuffix to ""
repeat theNestIndex times
set theFolderPrefix to theFolderPrefix & tab
set theFilePrefix to theFilePrefix & tab
if theTally is -1 then
set theSuffix to text item theTally of theLine & theSuffix
else
set theSuffix to text item theTally of theLine & ":" & theSuffix
end if
set currentIndex to "" & theFolder & theSuffix
set theTally to theTally - 1
end repeat
end if
set my text item delimiters to ""
if theLine is not "" then
if word 1 of theLine is "Volumes" then
set end of newList to theFolderPrefix & "Folder: > " &
currentFolder & return
else
try
if not folder of (info for alias (currentIndex & theLine & ":"))
then
set end of newList to theFilePrefix & tab & tab & tab & "> "
& theLine & return
end if
end try
end if
end if
end repeat
open for access file ((path to desktop as string) & "Contents of folder
- " & theName) with write permission returning theFile
write (newList as string) to theFile
close access theFile
--========================
TIA for any input.
Nick
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.