home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / internet / readnews / Scripts / Archiver next >
Encoding:
Text File  |  1994-04-17  |  3.2 KB  |  148 lines

  1. #Script Archive files (v0.04)
  2. #
  3. # This script provides an easy to use frontend for three popular
  4. # CLI archiving utilities (ARC, LHarc, and Tar) which you must have
  5. # installed in your current Library directory. In all cases it will
  6. # cause a new archive to be created and the specified files to be
  7. # added to it.
  8. #
  9. #Menu Archiver:arc,lharc,tar|compress\tar,zip
  10. #Arg Send to:
  11. #Width 10
  12. #Arg Archive name:
  13. #Width 40,80
  14. #Arg Filenames:
  15. #Args
  16. #
  17. # First, some range checking...
  18. #
  19. #if "%2%"=""
  20. #error You must specify an archive name to create!
  21. #endif
  22. #if "%3%"=""
  23. #error You must specify at least one file to archive!
  24. #endif
  25. #
  26. # Now initialise variables
  27. #
  28. #os Dir <ReadNews$TempDir>
  29. #if "<tar$scrap>"=""
  30. #os set tar$scrap <ReadNews$TempDir>.TarScrap
  31. #endif
  32. #os set Alias$Archiving %0% m %2%
  33. #
  34. # If we are zipping, change the command slightly
  35. #
  36. #if "%0%"="zip"
  37. #os set Alias$Archiving zip -rm %2%
  38. #os cdir %2%
  39. #endif
  40. #
  41. # If we are tarring, create a blank tarchive now...
  42. #
  43. #if "%0%"="tar"
  44. #task tar cf %2% null:
  45. #endif
  46. #
  47. # Copy all files into temp directory
  48. #   - If tarring, archive them and delete them as well
  49. #     as Tar has no MOVE option.
  50. #
  51. #repeat
  52. #os set leaf ""
  53. #os set branch "%3%"
  54. #while (branch RIGHT 1 <> ".") AND LEN branch > 0
  55. #os seteval leaf (branch RIGHT 1)+leaf
  56. #os seteval branch (branch LEFT (LEN branch - 1))
  57. #endwhile
  58. #task copy %3% <leaf> ~cq~v
  59. #if "%0%"="tar"
  60. #os set Alias$Archiving tar rf %2% <leaf>
  61. #task Archiving
  62. #os remove <leaf>
  63. #else
  64. #os set Alias$Archiving <Alias$Archiving> <leaf>
  65. #endif
  66. #Shift 3
  67. #until "%3%"=""
  68. #
  69. # Archive them all if we are not tarring
  70. #
  71. #if "%0%"<>"tar"
  72. #task Archiving
  73. #endif
  74. #os unset Alias$Archiving
  75. #
  76. # Process archive name to make it uniform
  77. #  - ARC leaves filename unchanged
  78. #  - LHarc adds "_lzh" to end and truncates to 10 chars
  79. #  - Tar needs compressing, which truncates name to 8 chars and
  80. #    appends "-Z"
  81. #
  82. #os set leaf "%2%"
  83. #
  84. # LHarc code
  85. #
  86. #if "%0%"="lharc"
  87. #os seteval leaf (leaf + "_lzh") LEFT 10
  88. #endif
  89. #
  90. # zip code
  91. #
  92. #if "%0%"="zip"
  93. #os rename <leaf> _!!_!!_
  94. #os rename _!!_!!_.zip <leaf>
  95. #os delete _!!_!!_
  96. #endif
  97. #
  98. # Set the type of the file to Archive (strange!)
  99. #
  100. #os SetType <leaf> DDC
  101. #
  102. # Tar code
  103. #
  104. #if "%0%"="tar"
  105. #os seteval newleaf leaf LEFT 8
  106. #os rename <leaf> <newleaf>
  107. #os set leaf <newleaf>
  108. #os set Alias$Compressing compress <newleaf>
  109. #task Compressing
  110. #os unset Alias$Compressing
  111. #os seteval leaf (newleaf + "-Z") LEFT 10
  112. #os SetType <leaf> FFD
  113. #endif
  114. #
  115. # If an email address was not given, open the temp directory.
  116. # Otherwise UUencode and email the file, deleting it afterwards.
  117. #
  118. #if "%1%"=""
  119. #os Filer_OpenDir <ReadNews$TempDir>
  120. #else
  121. #Output post
  122. To: %1%
  123. Subject: uuencoded %0% archive within
  124.  
  125. The following is a uuencoded archive, created with %0%.
  126. Trim out everything before the first 'cut here' line and feed
  127. to a uudecoder/archive utility (eg Spark).
  128.  
  129. Original archive name: %2%
  130.  
  131. BEGIN---------- Cut Here ----------
  132. #os set Alias$UUencoding uue <leaf>
  133. #task UUencoding
  134. #os Unset Alias$UUencoding
  135. #os remove <leaf>
  136. #os seteval leaf leaf LEFT 6
  137. #include <leaf>_uue
  138. #os remove <leaf>_uue
  139. END------------ Cut Here ----------
  140. #endif
  141. #
  142. # Leave everything the way we found it!
  143. #
  144. #os unset leaf
  145. #os Unset newleaf
  146. #os unset branch
  147. #os Back
  148.