home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / Python 1.3 / Python 1.3 68K / scripts / MkPluginAliases.as < prev    next >
Encoding:
Text File  |  1995-10-11  |  2.6 KB  |  80 lines  |  [TEXT/ToyS]

  1. -- This AppleScript creates Finder aliases for all the
  2. -- dynamically-loaded modules that "live in" in a single
  3. -- shared library.
  4. -- It needs a scriptable finder, and it may need some common
  5. -- scripting additions (i.e. stuff that *I* happen to have:-)
  6. -- 
  7. -- If you compare it to MkPluginAliases.py it also serves
  8. -- as a comparison between python and AppleScript:-)
  9. --
  10. -- Jack Jansen, CWI, August 1995
  11.  
  12. -- G is a list of {target, original} tuples
  13.  
  14. set G to {{"mactcp.slb", "mactcpmodules.slb"}}
  15. set G to (G & {{"macdnr.slb", "mactcpmodules.slb"}})
  16. set G to (G & {{"AE.slb", "toolboxmodules.slb"}})
  17. set G to (G & {{"Ctl.slb", "toolboxmodules.slb"}})
  18. set G to (G & {{"Dlg.slb", "toolboxmodules.slb"}})
  19. set G to (G & {{"Evt.slb", "toolboxmodules.slb"}})
  20. set G to (G & {{"Menu.slb", "toolboxmodules.slb"}})
  21. set G to (G & {{"List.slb", "toolboxmodules.slb"}})
  22. set G to (G & {{"Qd.slb", "toolboxmodules.slb"}})
  23. set G to (G & {{"Res.slb", "toolboxmodules.slb"}})
  24. set G to (G & {{"Snd.slb", "toolboxmodules.slb"}})
  25. set G to (G & {{"Win.slb", "toolboxmodules.slb"}})
  26. set G to (G & {{"imgcolormap.slb", "imgmodules.slb"}})
  27. set G to (G & {{"imgformat.slb", "imgmodules.slb"}})
  28. set G to (G & {{"imggif.slb", "imgmodules.slb"}})
  29. set G to (G & {{"imgjpeg.slb", "imgmodules.slb"}})
  30. set G to (G & {{"imgop.slb", "imgmodules.slb"}})
  31. set G to (G & {{"imgpgm.slb", "imgmodules.slb"}})
  32. set G to (G & {{"imgppm.slb", "imgmodules.slb"}})
  33. set G to (G & {{"imgtiff.slb", "imgmodules.slb"}})
  34.  
  35. -- Find the plugins directory
  36. set Dir to choose folder with prompt "Where is the PlugIns directory?"
  37.  
  38. -- List everything there
  39. set AllFiles to list folder Dir
  40.  
  41. -- Remove .slb aliases and remember .slb files
  42. display dialog "About to remove old .slb aliases"
  43. set LibFiles to {}
  44. repeat with F in AllFiles
  45.     if F ends with ".slb" then
  46.         set fileRef to ((Dir as text) & F) as alias
  47.         set Info to info for fileRef
  48.         if alias of Info then
  49.             tell application "Finder"
  50.                 move fileRef to trash
  51.             end tell
  52.         else
  53.             set LibFiles to (LibFiles & F)
  54.         end if
  55.     end if
  56. end repeat
  57.  
  58. -- Open the folder, so we can talk to the finder about it
  59. tell application "Finder"
  60.     set FinderName to open (Dir as alias)
  61. end tell
  62.  
  63. -- The "real" mainloop: create the aliases
  64. display dialog "About to create new .slb aliases"
  65. repeat with Goal in G
  66.     set Dst to item 1 of Goal
  67.     set Src to item 2 of Goal
  68.     if LibFiles contains Src then
  69.         tell application "Finder"
  70.             set DstAlias to make alias to (((Dir as text) & Src) as alias)
  71.             set name of DstAlias to Dst
  72.         end tell
  73.     else
  74.         -- The original isn't there
  75.         display dialog "Skipping alias " & Dst & " to " & Src
  76.     end if
  77. end repeat
  78.  
  79. display dialog "All done!"
  80.