.;
.;----------------------------------------------------------------------------
.;
.; CMD-File:	RENAME
.;
.; Purpose:	Selectively renaming of files.
.;
.; Author:	Jan H. Belgraver
.;		Modified from COPY.CMD received from Han Lasance 
.;		in 1980.
.;
.; Date:	14-APR-83
.;
.; Version:	V1.4	1-JUL-85
.;
.; Modified by:	Jan H. Belgraver	14-DEC-84	JB03	1.3
.;		Sort directory first, and use SRD also for listing.
.;
.;		Jan H. Belgraver	1-JUN-85	JB04	V1.4
.;		do not remove 1st two characters of RECORD.
.;
.;----------------------------------------------------------------------------
.;
.enable substitution
.enable	quiet					
	.SETF	DCL				
	.IF	<CLI> EQ "DCL"	.SETT	DCL	
.;	If current CLI is DCL reset to MCR	
	.IFT	DCL	SET TERMINAL/MCR
.disable	quiet				
.;
.SETF	FLAG
.SETS	STRING ""
.;.SETF	GO
.SETT	GO
.SETF	PRINT					
.;
.;	ASK FOR COMMAND PARAMETERS IF NOT PRESENT
.;
.IF	P2 EQ ""	.ASKS P1 FROM	
.IF	P2 EQ ""	.ASKS P2 TO	
.;
.;	FIND OUT WHAT TO COPY
.;
.enable	quiet								! JB03
SRD	/NA/WB/NOLI							! JB03
SRD	DIRECTORY.TMP;1234='P1'/NA					! JB03
.;
.OPENR	DIRECTORY.TMP;1234
.LOOP:
	.SETS	PREVIO	STRING
	.READ	RECORD
	.IFT	<EOF>	.GOTO	EXIT
	.IF	<FILERR> NE 1	.GOTO	ERROR
	.TEST	RECORD
.;
.;	GET RID OF <CR><LF>
.;
	.SETS	STRING	RECORD						.;JB04
	.PARSE	STRING	".;"	NAME TYPE VERS
	.IF	TYPE EQ ""	.GOTO	LOOP
.;
.;	WATCH OUT FOR THE FILE ITSELF
.;
	.IF	NAME NE "DIRECTORY"	.GOTO	MORE
	.IF	TYPE NE "TMP"	.GOTO	MORE
	.IF	VERS NE "1234"	.GOTO	MORE
	.GOTO	LOOP
.MORE:
.disable	quiet							! JB03
.;	.IFT	GO	.GOTO	COPY
.;	.ASKS	ANSWER	Rename 'STRING' [Y,N,Q,G,^] ?
	.ASKS	ANSWER	Rename 'STRING' [Y,N,Q,] ?
	.IF	ANSWER EQ ""	.GOTO LOOP
	.SETS	FIRST	ANSWER [1:1]
	.IF	FIRST EQ "N"	.GOTO LOOP
	.IF	FIRST EQ "Y"	.GOTO RENAME
	.IF	FIRST EQ "Q"	.GOTO EXIT
.;	.IF	FIRST EQ "G"	.SETT GO
.;	.IF	FIRST EQ "^"	.SETT FLAG
.;	.IFT	GO	.ASK	PRINT	Printing filenames
.;	.IFT	GO	.GOTO	COPY
	.IFF	FLAG	.GOTO	MORE
	.SETS	CURREN	STRING
	.SETS	STRING	PREVIO
.RENAME:
	.IFT	PRINT	;	'STRING'
	.ASKS	NEWSTR	New filespec
	PIP	'P2''NEWSTR'='P1''STRING'/RE
	.IFF	FLAG	.GOTO	LOOP
	.SETF	FLAG
	.SETS	STRING	CURREN
	.GOTO	MORE
.ERROR:
	.disable	quiet
	;..... ERROR '<FILERR>' IN '<FILSPC>'
.EXIT:
	.enable	quiet							! JB02
	PIP	DIRECTORY.TMP;1234/DE
.FINISH:
	.enable	quiet							! JB02
	.;	If user CLI was DCL reset terminal.			! JB02
	.IFT	DCL	SET /DCL=TI:
	.disable display						! JB03
.EXIT
