home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / CDROM / RumeoAndJoliet / rumeo < prev    next >
AmigaDOS Script File  |  1999-10-15  |  4KB  |  135 lines

  1. .key CDLIST/A,SOURCECD/A,DESTPATH/A,OUTFILE/K,INCLUDERE/K,EXCLUDERE/K
  2. .bra {
  3. .ket }
  4.  
  5. ;
  6. ; Rumeo, the Joliet CD renamer
  7. ; By Jean-François Fabre 1999
  8. ;
  9. ; This script is part of the J.A.S.T software (JOTD Amiga Shell Tools)
  10. ; I think it's rather boring to write such a tool in C because of
  11. ; all the regular expression tools used here such as grep and sed,
  12. ; which as you can see are very powerful, and are of great help
  13. ; in the Amiga and Win9x world.
  14.  
  15. ; CDLIST: dirlist from a PC (ex: PC1:cdlist.txt)
  16. ; SOURCECD: CD mounted on the amiga (ex: CD0:)
  17. ; DESTPATH: destination (ex: BIG:MPEG3)
  18. ; OUTFILE: if specified, no copy done, copy script generated in OUTFILE
  19. ; INCLUDERE: regular expression to filter the list
  20. ; EXCLUDERE: regular expression to filter the list (remove the matching lines)
  21.  
  22. ; This program needs:
  23. ;
  24. ; * interlace_files (home-made tool)
  25. ; * simplecopy (home-made tool)
  26. ; * gnused (GNU version of sed)
  27. ; * grep (GNU version of grep)
  28. ; * tr (any version is OK)
  29. ; * multifr (from Lionel Vintenat)
  30. ; * uniq (any version is OK)
  31. ; * mkdir (GNU version is OK, Amiga makedir lacks -p option)
  32. ; * sort (amigaOS)
  33. ; * find (amigaOS external command)
  34. ;
  35. ; NOTES:
  36. ; - The amiga LIST command is buggy with dirnames containing the ~ character
  37. ;   (loops forever) that's why I used find instead
  38. ;
  39. ; - mkdir is needed because of the -p option that amiga makedir does not have
  40. ;
  41. ; - GNU sed works, minix sed exits because of RE too big
  42. ; - simplecopy copies the files just like copy, but no problem with ~ names
  43. ;
  44. ; - Set stack to at least 20000 bytes (grep needs lots of stack space)
  45.  
  46. ; all those tools are included in the distribution
  47.  
  48. ; set environment variables
  49.  
  50. set OUTFILE ""
  51. set OUTFILE {OUTFILE}
  52.  
  53. set SED gnused        ; change by sed if necessary
  54.  
  55. set EXCLUDERE "{EXCLUDERE}"
  56. set INCLUDERE "{INCLUDERE}"
  57.  
  58. ; replace \ by /
  59.  
  60. tr "\\" "/" < {CDLIST} > T:cdlist.2
  61.  
  62. ; suppress shitty ^M (PC linefeed)
  63.  
  64. tr -d "\015" < T:cdlist.2 > T:cdlist
  65.  
  66. ; replace the CD volume name by the destination name
  67. ; suppress spaces and cut names bigger than 30 characters
  68.  
  69. $SED -e "s#(.**)##g" -e "s#.**:#{DESTPATH}#" -e "s#[' ][' ]**##g" -e "s#^\(.**/[^/][^/][^/][^/][^/][^/][^/][^/][^/][^/][^/][^/][^/][^/][^/][^/][^/][^/][^/][^/][^/][^/][^/][^/][^/]\)[^/]**\.\([^/]**\)#\1.\2#" T:cdlist > T:cdlist.2
  70. sort T:cdlist.2 TO T:cdlist.3
  71.  
  72. $SED "s#\(.**\)/.***$#mkdir -p *"\1*"#" T:cdlist.2 > T:cddirs.1
  73. uniq T:cddirs.1 > T:cddirs.2
  74.  
  75. ; unable to use list here: it's buggy with names with ~ in it !!
  76.  
  77. ;;;list LFORMAT %f%s FILES ALL {SOURCECD} > T:cdamiga.1
  78. find #? {SOURCECD} > T:cdamiga.1
  79.  
  80. interlace_files T:cdamiga.1 T:cdlist.3 > T:cddirs.4
  81. $SED "s#.**#simplecopy &#" T:cddirs.4 >> T:cddirs.2
  82.  
  83. ; remove braces and text within them
  84. ; replace :/ by :
  85.  
  86. $SED -e "s#(.**)##g" -e "s#:/#:#" T:cddirs.2 > T:cddirs.1
  87.  
  88. ; if INCLUDERE is set, consider lines only if they match the
  89. ; regexp passed in argument
  90.  
  91. if NOT EQ "$INCLUDERE.k" ".k"
  92.   grep -i "$INCLUDERE" T:cddirs.1 > T:cddirs.2
  93.   copy T:cddirs.2 T:cddirs.1
  94. endif
  95.  
  96. ; if EXCLUDERE is set, discard lines matching the
  97. ; regexp passed in argument
  98.  
  99. if NOT EQ "$EXCLUDERE.k" ".k"
  100.   grep -i -v "$EXCLUDERE" T:cddirs.1 > T:cddirs.2
  101.   copy T:cddirs.2 T:cddirs.1
  102. endif
  103.  
  104. ; remove the accents if any
  105.  
  106. multifr >NIL: HFS 82 RS e T:cddirs.1
  107. multifr >NIL: HFS 88 RS e T:cddirs.1
  108. multifr >NIL: HFS 8A RS e T:cddirs.1
  109. multifr >NIL: HFS 8B RS i T:cddirs.1
  110. multifr >NIL: HFS 93 RS o T:cddirs.1
  111.  
  112. ; if OUTFILE is not set, directly run the copy script
  113.  
  114. if EQ "$OUTFILE.k" "$OUTFILE"
  115.   execute T:cddirs.1
  116. else
  117.   copy T:cddirs.1 $OUTFILE
  118.   protect $OUTFILE s add
  119. endif
  120.  
  121. ; cleanup env variables
  122.  
  123. unset OUTFILE
  124. unset INCLUDERE
  125. unset EXCLUDERE
  126. unset SED
  127.  
  128. ; cleanup
  129.  
  130. delete T:cd#? quiet
  131.  
  132. ; end
  133.