Thanks Charlie and James, this did it and was exactly what I wanted. One more question, what is the syntax to find unmatched files?
Thanks again!
Here is the code I finally put together.
######################################################################
# Name: billing_dupfilecheck
# Purpose:
# UPoC type: tps
# Args: tps keyedlist containing the following keys:
# MODE run mode (“start”, “run” or “time”)
# MSGID message handle
# ARGS user-supplied arguments:
#
#
# Written By: Femina Jaffer on Nov. 11, 07
# This proc checks for duplicate files before processing files.
#
# Returns: tps disposition list:
#
#
proc billing_dupfilecheck { args } {
keylget args MODE mode ;# Fetch mode
set dispList {} ;# Nothing to return
switch -exact — $mode {
start {
# Perform special init functions
# N.B.: there may or may not be a MSGID key in args
}
run {
# ‘run’ mode always has a MSGID; fetch and process it
keylget args MSGID mh
# set directory paths of files to compare
set dir /home/hci/
set in_dir /home/hci/temp/
# find the list of files in the first directory
set fileList1 [glob -nocomplain -directory $dir -types f -tails *.DAT]
# find the list of files in the second directory
set fileList2 [glob -nocomplain -directory $in_dir -types f -tails *.DAT]
# match files from both directories
set matched [intersect $fileList1 $fileList2]
if {$matched !=””} {
set fname [file root $matched]
echo matched $matched
# change directory
cd $dir
# copy the $matched file to another directory
echo copying matched file
file copy $dir/$matched $matched.DAT
}
}
time {
# Timer-based processing
# N.B.: there may or may not be a MSGID key in args
}
shutdown {
# Doing some clean-up work
}
default {
error “Unknown mode ‘$mode’ in blank”
}
}
return $dispList
}