#!/bin/csh -fe # "@(#) $Id: RestoreID,v 1.32 2002/01/29 05:36:57 vltsccm Exp $" ############################################################################# # Copyright: J.Brewer/ESO 1999.############################################## ############################################################################# # # Name: RestoreID # Description: This script will extract the original names for WFI images # on disk, and optionally rename the images to their original names. # # # Author: James Brewer, jbrewer@eso.org # Version: 1.0, 5 May99: First release # ############################################################################# if($#argv == 0 || $1 == "-help") then goto error endif # # Set variables. # set tmp = RestoreID.tmp # Name for a tmp file... # # Go through the list of fits files... # foreach file ($*) # # Ignore the `-show' argument... # if ($file == '-show') then continue endif # # If file doesn't exist, skip to next one... # if !(-r $file) then echo $0": Unable to read "$file", skipping to next file..." continue endif # # Read the header info of the fits file.... # (dd if=$file ibs=2880 count=5 obs=80 cbs=80 conv=unblock | tr ' ' '_' >! $tmp) >>& /dev/null set Line = "OXOXO" # # Find line containing original name, and extract. Edit the below # According to when you obtained your data... # # WFI Files before May99: #set Line = `cat $tmp | grep ESO_DET_EXP_ID | tr '_' ' '` #set Orig = wfi`echo $Line | tr -s ' ' | cut -f7 -d' '`.fits # # WFI Files after May99: # set Line = `cat $tmp | grep ORIGFILE | tr '_' ' '` # set Orig = `echo $Line | tr '\047' '\012' | tail -2 | head -1 | tr ' ' '_'` # # For DFOSC data... #set Line = `cat $tmp | grep FILENAME= | tr '_' ' '` #set Orig = `echo $Line | tr '\047' '\012' | tail -2 | head -1` # For VLT-like data... # set Line = `cat $tmp | grep ARCFILE | tr '_' ' '` # set Orig = `echo $Line | tr '\047' '\012' | tail -2 | head -1` # # Check to see whether a name was recovered... # if(`echo $Line | wc -c` == 0) then echo $file": No name recovered, skipping to next file..." continue endif # # Show/execute the mv command... # if($1 == '-show') then echo "show mode: mv "$file $Orig else if (-e $Orig) then echo $Orig" exists: no action taken..." else echo "Executing --> mv "$file $Orig mv $file $Orig endif endif end # # delete the last tmp file... # rm -f $tmp exit(0) error: echo "Usage (1): "$0" -show file1 file2 filen" echo " >>> show mode, nothing renamed" echo " " echo "Usage (2): "$0" file1 file2 filen" echo " >>> restore original names" echo " " echo " " echo "[Further information --> "$0" -help]" echo "[See this script --> more `which "$0"`]" if($1 == "-help") then more `echo $0 | tr 'RestoreID' ' ' | cut -f1 -d ' '`ObsLog.man endif exit(-1)