source: branches/Mars_use_drstimefiles/datacenter/tools/rename_rawfiles@ 18656

Last change on this file since 18656 was 9097, checked in by snruegam, 16 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 2.2 KB
Line 
1#!/bin/sh
2#
3# ========================================================================
4#
5# *
6# * This file is part of MARS, the MAGIC Analysis and Reconstruction
7# * Software. It is distributed to you in the hope that it can be a useful
8# * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
9# * It is distributed WITHOUT ANY WARRANTY.
10# *
11# * Permission to use, copy, modify and distribute this software and its
12# * documentation for any purpose is hereby granted without fee,
13# * provided that the above copyright notice appear in all copies and
14# * that both that copyright notice and this permission notice appear
15# * in supporting documentation. It is provided "as is" without express
16# * or implied warranty.
17# *
18#
19#
20# Author(s): Stefan Ruegamer 07/2008 <mailto:snruegam@astro.uni-wuerzburg.de>
21#
22# Copyright: MAGIC Software Development, 2000-2008
23#
24#
25# ========================================================================
26#
27# This script searches for raw files with a 5 digit subrun number and
28# changes this number to a 3 digit one.
29
30
31source `dirname $0`/sourcefile
32program=rename_rawfiles
33
34scriptlog=$runlogpath/$program-$datetime.log
35date >> $scriptlog 2>&1
36
37# check if script is already running
38lockfile=$lockpath/lock-$program.txt
39checklock >> $scriptlog 2>&1
40
41rawdatapath=/data/fromtape/muxdata
42
43# find raw files named after the new convention but having a 5 digit subrun number
44files=`find ${rawdatapath}/ -regextype posix-egrep -regex '.*/20[01][0-9]{5}_M[12]_[0-9]{8}\.[0-9]{5}_.*.raw' -type f`
45
46# convert to 3 digit subrun number
47for file in ${files[@]}
48do
49 zero=`basename $file | cut -d_ -f3 | cut -c 10-11`
50 if ! [ $zero == "00" ]
51 then
52 echo "${file}: subrunnumber greater than 999 -> continue" >> $scriptlog 2>&1
53 continue
54 else
55 # s/ ()() / \1\2 /
56 newfile=`echo $file | sed -e 's/\(.*\/20[01][0-9]\{5\}_M[12]_[0-9]\{8\}\.\)00\([0-9]\{3\}.*\)/\1\2/'`
57 # raw files without .-separation between run and subrun number and without M[12]
58 #newfile=`echo $file | sed -e 's/\(.*20[01][0-9]\{5\}_\)\([0-9]\{8\}\)00\([0-9]\{3\}.*\)/\1M1_\2.\3/'`
59 echo "moving $file to $newfile..." >> $scriptlog 2>&1
60 mv $file $newfile
61 fi
62done
63
64rm -v $lockfile >> $scriptlog 2>&1
65
Note: See TracBrowser for help on using the repository browser.