home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 3
/
AACD03.BIN
/
AACD
/
CDROM
/
RumeoAndJoliet
/
rumeo
< prev
next >
Wrap
AmigaDOS Script File
|
1999-10-15
|
4KB
|
135 lines
.key CDLIST/A,SOURCECD/A,DESTPATH/A,OUTFILE/K,INCLUDERE/K,EXCLUDERE/K
.bra {
.ket }
;
; Rumeo, the Joliet CD renamer
; By Jean-François Fabre 1999
;
; This script is part of the J.A.S.T software (JOTD Amiga Shell Tools)
; I think it's rather boring to write such a tool in C because of
; all the regular expression tools used here such as grep and sed,
; which as you can see are very powerful, and are of great help
; in the Amiga and Win9x world.
; CDLIST: dirlist from a PC (ex: PC1:cdlist.txt)
; SOURCECD: CD mounted on the amiga (ex: CD0:)
; DESTPATH: destination (ex: BIG:MPEG3)
; OUTFILE: if specified, no copy done, copy script generated in OUTFILE
; INCLUDERE: regular expression to filter the list
; EXCLUDERE: regular expression to filter the list (remove the matching lines)
; This program needs:
;
; * interlace_files (home-made tool)
; * simplecopy (home-made tool)
; * gnused (GNU version of sed)
; * grep (GNU version of grep)
; * tr (any version is OK)
; * multifr (from Lionel Vintenat)
; * uniq (any version is OK)
; * mkdir (GNU version is OK, Amiga makedir lacks -p option)
; * sort (amigaOS)
; * find (amigaOS external command)
;
; NOTES:
;
; - The amiga LIST command is buggy with dirnames containing the ~ character
; (loops forever) that's why I used find instead
;
; - mkdir is needed because of the -p option that amiga makedir does not have
;
; - GNU sed works, minix sed exits because of RE too big
;
; - simplecopy copies the files just like copy, but no problem with ~ names
;
; - Set stack to at least 20000 bytes (grep needs lots of stack space)
; all those tools are included in the distribution
; set environment variables
set OUTFILE ""
set OUTFILE {OUTFILE}
set SED gnused ; change by sed if necessary
set EXCLUDERE "{EXCLUDERE}"
set INCLUDERE "{INCLUDERE}"
; replace \ by /
tr "\\" "/" < {CDLIST} > T:cdlist.2
; suppress shitty ^M (PC linefeed)
tr -d "\015" < T:cdlist.2 > T:cdlist
; replace the CD volume name by the destination name
; suppress spaces and cut names bigger than 30 characters
$SED -e "s#(.**)##g" -e "s#.**:#{DESTPATH}#" -e "s#[' ][' ]**##g" -e "s#^\(.**/[^/][^/][^/][^/][^/][^/][^/][^/][^/][^/][^/][^/][^/][^/][^/][^/][^/][^/][^/][^/][^/][^/][^/][^/][^/]\)[^/]**\.\([^/]**\)#\1.\2#" T:cdlist > T:cdlist.2
sort T:cdlist.2 TO T:cdlist.3
$SED "s#\(.**\)/.***$#mkdir -p *"\1*"#" T:cdlist.2 > T:cddirs.1
uniq T:cddirs.1 > T:cddirs.2
; unable to use list here: it's buggy with names with ~ in it !!
;;;list LFORMAT %f%s FILES ALL {SOURCECD} > T:cdamiga.1
find #? {SOURCECD} > T:cdamiga.1
interlace_files T:cdamiga.1 T:cdlist.3 > T:cddirs.4
$SED "s#.**#simplecopy &#" T:cddirs.4 >> T:cddirs.2
; remove braces and text within them
; replace :/ by :
$SED -e "s#(.**)##g" -e "s#:/#:#" T:cddirs.2 > T:cddirs.1
; if INCLUDERE is set, consider lines only if they match the
; regexp passed in argument
if NOT EQ "$INCLUDERE.k" ".k"
grep -i "$INCLUDERE" T:cddirs.1 > T:cddirs.2
copy T:cddirs.2 T:cddirs.1
endif
; if EXCLUDERE is set, discard lines matching the
; regexp passed in argument
if NOT EQ "$EXCLUDERE.k" ".k"
grep -i -v "$EXCLUDERE" T:cddirs.1 > T:cddirs.2
copy T:cddirs.2 T:cddirs.1
endif
; remove the accents if any
multifr >NIL: HFS 82 RS e T:cddirs.1
multifr >NIL: HFS 88 RS e T:cddirs.1
multifr >NIL: HFS 8A RS e T:cddirs.1
multifr >NIL: HFS 8B RS i T:cddirs.1
multifr >NIL: HFS 93 RS o T:cddirs.1
; if OUTFILE is not set, directly run the copy script
if EQ "$OUTFILE.k" "$OUTFILE"
execute T:cddirs.1
else
copy T:cddirs.1 $OUTFILE
protect $OUTFILE s add
endif
; cleanup env variables
unset OUTFILE
unset INCLUDERE
unset EXCLUDERE
unset SED
; cleanup
delete T:cd#? quiet
; end