home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga MA Magazine 1998 #6
/
amigamamagazinepolishissue1998.iso
/
cdrom
/
optycdplayer
/
extras
/
utils
/
disknote.rexx
next >
Wrap
OS/2 REXX Batch file
|
1977-12-31
|
2KB
|
112 lines
/* $VER: DiskNote.rexx 1.1 (21.7.96)
Puts a filenote on a file, consisting of the two first lines
in the file, separated by ": ". This has the effect - for
Disk Files for e.g. OptyCDPlayer - of making the author and
title visible in a directory listing or utility.
© Niels Bache (nbache@diku.dk), 14/7-96. Freely distributable.
Specifically, Stéphane 'Opty' Barbaray is welcome to include
this with future releases of his great OptyCDPlayer program.
History:
Version 1.1, 21/7-96:
· Now handles authors/titles with double quotes and/or asterisks
in them, by escaping them with asterisks.
· If author or title is empty, now just gives a warning and uses
the other one alone, with no colon.
· If both are missing, it still quits, since there is nothing to
put in the filenote.
· Also now just gives a warning if no track titles are found.
*/
parse arg File .
File = strip(File, 'B', '"')
NoAuth = 0
NoTitl = 0
if length(File) <= 0 then do
say "No file name given!"
exit 10
end
if ~open('In', File, 'R') then do
say "File not found!"
exit 10
end
if eof('In') then do
say "File empty!"
exit 10
end
Line1 = readln('In')
if length(Line1) <= 0 then do
say "WARNING: No author found in file!"
NoAuth = 1
end
if eof('In') then do
say "File too short!"
exit 10
end
Line2 = readln('In')
if length(Line2) <= 0 then do
say "WARNING: No CD title found in file!"
NoTitl = 1
end
if eof('In') then do
say "WARNING: No track titles found in file!"
end
call close('In')
if NoAuth & NoTitl then do
say "Neither author nor CD title found!"
exit 10
end
Sep = ": "
if NoAuth | NoTitl then Sep = ""
Note = Line1 || Sep || Line2
if Length(Note) > 79 then do
Note = left(Note, 78) || "»"
end
Done = 0
Start = 1
do while ~Done
APos = pos('*', Note, Start)
if APos > 0 then do
Note = left(Note, APos - 1) || '*' || substr(Note, APos)
Start = APos + 2
if Start > length(Note) then Done = 1
end
else Done = 1
end
Done = 0
Start = 1
do while ~Done
QPos = pos('"', Note, Start)
if QPos > 0 then do
Note = left(Note, QPos - 1) || '*' || substr(Note, QPos)
Start = QPos + 2
if Start > length(Note) then Done = 1
end
else Done = 1
end
Note = '"' || Note || '"'
MyCmd = "filenote " || File || " " || Note
address command MyCmd
if RC ~= 0 then do
say "Error (RC = " || RC || ") while setting file note!"
exit 10
end
exit 0