From:	MERC::"uunet!CRVAX.SRI.COM!RELAY-INFO-VAX" 12-JUL-1992 17:07:13.28
To:	info-vax@kl.sri.com
CC:	
Subj:	Re: Program to "rewind" file versions to ;1 ... the saga continues

In article <22071009273213@psl.wisc.edu>, JRW@PSL.WISC.EDU ("Jim Winkle, UW-PSL, 608-873-6651") writes:
>
>    I recently posted the query:
>
>>      Hi.  Does anyone have a program (preferrably in DCL) that
>> will "rewind" file versions back to version 1 for all files on a
>> disk?  
>
>and received many responses, of the form:
>
>	$ PURGE
>	$ RENAME *.*;* *.*;1
>
>I should have been more specific about my query, because I want to "rewind" 
>ALL versions of a file, keeping as many versions that exist.  For example:
>
>	FILE.TYP;32767
>	FILE.TYP;32766
>	FILE.TYP;32765
>
>	becomes
>
>	FILE.TYP;3
>	FILE.TYP;2
>	FILE.TYP;1
>
>A couple of people caught this, and said they would be interested in the
>solution, so again, if you have a program that will do this, please send
>directly to me.  Someone in VAXland must have solved this problem by now!
>Or maybe in VMS 6.0, we'll get "$SET FILE / REWIND_VERSIONS".  :)  Thanks 
>again!  Jim.

Well, I'd never solved it before, but with about 20 minutes effort I came up
with the following.  Hope it helps.

$	if p1 .nes. "" then goto lbl0
$	read/prompt="Filespec: " sys$command p1
$ lbl0:	file = f$search(p1, 1)
$	if file .eqs. "" then exit
$	high_version = f$integer(f$parse(file,,,"VERSION") - ";")
$	base_name = file - ";''high_version'"
$	file = f$search(base_name+";-0")
$	low_version = f$integer(f$parse(file,,,"VERSION") - ";")
$	if low_version .eq. 1 then goto lbl0
$	low_version = low_version - 1
$	versions = high_version - low_version
$	n = 1
$ lbl1:	if n .gt. versions then goto lbl0
$	m = n + low_version
$	if f$search(base_name+";''m'", 2) .nes. "" then -
$	rename/log 'base_name';'m' 'base_name';'n'
$	n = n + 1
$	goto lbl1
--------------------------------------------------------------------------------
Carl J Lydick | INTERnet: CARL@SOL1.GPS.CALTECH.EDU | NSI/HEPnet: SOL1::CARL

Disclaimer:  Hey, I understand VAXen and VMS.  That's what I get paid for.  My
understanding of astronomy is purely at the amateur level (or below).  So
unless what I'm saying is directly related to VAX/VMS, don't hold me or my
organization responsible for it.  If it IS related to VAX/VMS, you can try to
hold me responsible for it, but my organization had nothing to do with it.

