• 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: Droplet alias lists was Re: URL access scripting
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Droplet alias lists was Re: URL access scripting


  • Subject: Re: Droplet alias lists was Re: URL access scripting
  • From: Nigel Garvey <email@hidden>
  • Date: Sun, 16 Dec 2001 19:26:23 +0000

On Saturday, December 15, 2001, at 06:23 AM, Gnarlodious wrote:

> I don't know abour8.1 but here is a droplet that will make a text file
> of
> aliases of all files in a folder including subfolders;
>
> on open (Dropped)
> set AppleScript's text item delimiters to return
> tell application "Finder"
> write ((entire contents of (Dropped as alias)) as text) to
> (make new
> file at desktop)
> set creator type of file "Apple:Desktop Folder:untitled" to
> "TBB6"
> end tell
> end open

To which entity Bryan Kobler replied on Sat, 15 Dec 2001 11:10:49 -0700:

>That is basically what I have and it works with 9.2.1. My problem is
>8.1 doesn't work. So this is what I was thinking from previous scripts
>I have seen....

This isn't particularly swift, but it's not too bad. It produces nice
results too:

on open dropped
set theTargetFile to new file with prompt "Save the text file as...?"
-- Initalise a list for the lines of the text file
set theList to {"(Listing compiled: " & (current date) & ")" & return}

repeat with thisItem in dropped
beep 2 -- just to show the droplet's at work
if (thisItem as string) ends with ":" then
set the end of theList to "Contents of folder " & thisItem
listHierarchy(thisItem, theList, " ")
else
set the end of theList to "(The dropped item " & thisItem & "
wasn't a disk or a folder.)"
end if
set the end of theList to ""
end repeat

-- Coerce the list to a single string with returns
set AppleScript's text item delimiters to {return}
set theList to "" & theList
set AppleScript's text item delimiters to {""}

set fileRef to open for access theTargetFile with write permission
set eof fileRef to 0
write theList to fileRef
close access fileRef
end open

on listHierarchy(thisFolder, theList, thisInset)
beep -- just to show the droplet's at work
-- Get the names of this folder's items
set folderContents to list folder thisFolder without invisibles
-- Prepend inset padding to each
repeat with thisName in folderContents
set thisName's contents to thisInset & thisName
end repeat
try
tell application "Finder"
-- Get the index of every subfolder of this folder.
-- (The indices seem to follow the alphabetical order, like 'list
folder'.)
-- Modify the entries for the respective items in the 'list
folder' list
-- and replace them with sublists. Recurse to fill the sublists
with
-- listings for the subfolders.
repeat with i in (the index of every folder of thisFolder) as list
set item i of folderContents to (item i of folderContents & ":
(folder)") as list
my listHierarchy(get item i of thisFolder, item i of
folderContents, thisInset & " ")
end repeat
end tell
on error
-- No subfolders, so can't get their indices
end try
if folderContents is not {} then set the end of theList to
folderContents
end listHierarchy

NG


  • Prev by Date: Analysing folder contents in 8.1 (was URL access scripting)
  • Next by Date: Re: Analysing folder contents in 8.1 (was URL access scripting)
  • Previous by thread: Re: Analysing folder contents in 8.1 (was URL access scripting)
  • Next by thread: List limits
  • Index(es):
    • Date
    • Thread