Article 156992 of comp.os.vms:

In article <3262813D.575A@honeywell.com>, Jim Urquhart <jim.urquhart@honeywell.com> writes...
>Is there a way to run Diff to compare a directory of files to another
>directory containing the same filenames?
> 
please excuse the length of the following:

-------------------------------<cut here>----------------------------------
$! COMPARE.COM
$!
$! Compares all files in two directories and flags files that are different.
$!
$! Note:	*** Changed to accept logical names 17/2/1994 ***
$!		If input parameters are lists (e.g. logical names)
$! 		then activate command-file in the form
$!		@compare dir_list1 dir_list2
$!		(NOT dir_list1: dir_list2:)
$!
$! Special symbols
$	mess_state = f$envir("MESSAGE")
$	ws = "write sys$output"
$	wo = "write outfil"
$	delete = "delete"
$	do_diff = "differences/ign=(bla,form,trail,spac,exact)/comment=""!""/paral/wid=160"
$!
$! Input directories to be compared
$	if p1 .eqs. "" then inquire p1 "Input directory (no wild card)"
$	if p1 .eqs. "" then exit
$	if p2 .eqs. "" then inquire p2 "Comparison directory (no wild card)"
$	if p2 .eqs. "" then exit
$!
$! File name & type to be compared
$	filnam = f$parse(p1,"*.*",,"NAME") + -
		f$parse(p1,"*.*",,"TYPE")
$	if filnam .nes. "*.*"
$	then
$		p1 = p1 - ( f$parse(filnam,"*.*",,"NAME") +  -
			f$parse(filnam,"*.*",,"TYPE") ) 
$	else
$		p1 =  p1 - "*.*"
$	endif
$!
$! Cut end ":" off logical name
$	if f$extract( (f$length(p1)-1),1,p1 ) .eqs. ":"
$	then
$		tmp = f$extract( 0,(f$length(p1)-1),p1 )
$		if ( f$trnlnm( "''tmp'",,0 ) .nes. "" ) then p1 = tmp
$	endif
$!
$	if f$extract( (f$length(p2)-1),1,p2 ) .eqs. ":"
$	then
$		tmp = f$extract( 0,(f$length(p2)-1),p2 )
$		if ( f$trnlnm( "''tmp'",,0 ) .nes. "" ) then p2 = tmp
$	endif
$!
$	ws "Comparing file(s) ''filnam'"
$!
$!
$	proc = f$environment("PROCEDURE")
$	outfil_name = f$parse(proc,,,"NAME") + ".out"
$!
$	if f$trnlnm( "''p2'" ) .nes. ""
$	then
$		cmp = "''p2':"
$	else
$		cmp = f$parse(p2)
$		if cmp .eqs. "" then exit
$		cmp = cmp - ".;"
$	endif
$	ws "Compare with: ", cmp
$!
$	index = 0
$	tmp = f$trnlnm( "''p1'",,index )
$	if tmp .nes. ""
$	then
$		ref = tmp + filnam
$		ws "Ref ''index': ", ref,"  file:",filnam
$	else
$		ref = f$parse(p1)
$		if ref .eqs. "" then exit
$		ref = ref - ".;"
$		ws "Ref: ", ref
$		if f$locate("*",ref) .eq. f$length(ref) then-
			ref = ref + filnam
$	endif
$!
$! Known error codes
$	no_diff = %X006C8009
$	fnf = "%X106C109C"
$	no_low = "%X106C8064"
$	adiff = "%X006C8013"
$!
$! Initialization
$	count = 0
$	c_fnf = 0
$	c_ok = 0
$	c_dif = 0
$	c_unk = 0
$	context = 0
$	junk = f$search("",context)
$	set noon
$	on control_y then goto control_y_exit
$	open/write outfil 'outfil_name'
$	wo "Reference directory is ''ref'"
$	wo "Comparison directory is ''cmp'"
$	wo ""
$ again:
$	fil = f$search("''ref'",context)
$	if fil  .eqs. "" then goto done
$	count = count + 1
$	fn = f$parse(fil,,,"name") + f$parse(fil,,,"type")
$	df = f$parse(fil,,,"name") + "_" + f$parse(fil,,,"type") - "." + ".dif"
$	cmpn = f$sear( "''cmp'''fn'" )
$!
$	if cmpn .nes. ""
$	then
$		set message/nof/noi/nos/not	! Avoid "FNF.." messages
$		do_diff 'fil' 'cmpn'/out='df'
$		code = $status
$		set message'mess_state'
$	else
$		code = fnf
$	endif
$!
$	if code .eq. no_diff
$		then
$		wo f$fao("!4SL !36AS  ok.", count, fn)
$		ws f$fao("!4SL !36AS  ok.", count, fn)
$		delete/nolog 'df';*
$		c_ok = c_ok + 1
$		goto again
$		endif
$	if code .eq. fnf
$		then
$		wo f$fao("!4SL !36AS  not found in comparison directory", count, fn)
$		ws f$fao("!4SL !36AS  not found in comparison directory", count, fn)
$		c_fnf = c_fnf + 1
$		goto again
$		endif
$	if code .eq. adiff 
$		then
$		wo f$fao("!4SL !36AS  files are different", count, fn)
$		ws f$fao("!4SL !36AS  files are different", count, fn)
$		c_dif = c_dif + 1
$		goto again
$		endif
$!
$	wo "''fn' returned unknown error code ", code
$	ws "''fn' returned unknown error code ", code
$	c_unk = c_unk + 1
$	goto again
$!
$ control_y_exit:
$	index = index + 1
$	goto finish
$!
$ done:
$	index = index + 1
$	ref = f$trnlnm( "''p1'",,index )
$	if ( ref .nes. "" )
$	then
$		ws "Ref ''index': ", ref
$		wo ""
$		wo "Ref ''index': ", ref
$		ref = ref + filnam
$		goto again
$	endif
$!
$ finish:
$	tmp = ""
$	if index .gt. 0 then -
	tmp = f$fao(",in !3SL director!1%Cy!%Eies!%F",index)
$	wo ""
$	wo f$fao("Processed !SL file!%S on !%D ''tmp'", count, 0)
$	wo f$fao(" !4SL file!%S !1%Cwas!%Ewere!%F identical", c_ok)
$	wo f$fao(" !4SL file!%S !1%Cwas!%Ewere!%F different", c_dif)
$	wo f$fao(" !4SL file!%S !1%Cwas!%Ewere!%F not found", c_fnf)
$	wo f$fao(" !4SL file!%S returned unknown errors", c_unk)
$	close outfil
$	tmp = ""
$	if index .gt. 0 then -
	tmp = f$fao(",in !3SL director!1%Cy!%Eies!%F",index)
$	ws ""
$	ws f$fao("Processed !SL file!%S on !%D ''tmp'", count, 0)
$	ws f$fao(" !4SL file!%S !1%Cwas!%Ewere!%F different", c_dif)
$	ws f$fao(" !4SL file!%S !1%Cwas!%Ewere!%F not found", c_fnf)
$	ws f$fao(" !4SL file!%S returned unknown errors", c_unk)
$	set message'mess_state'
$	exit
-------------------------------<cut here>----------------------------------
... enjoy!
Mike

-------------------------------------------------------------------------------
Usual disclaimers apply. All my opinions are mine alone - perhaps not even that.
Mike Rechtman           rechtman@shani.net  (work rechtman@taveng.enet.dec.com)
Kibbutz Tzor'a.                                     Voice (home): 972-2-9908337
PSI%425120012117::Mike            calling card: http://shani.net/USERS/rechtman
-------------------------------------------------------------------------------


