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 |
|
---|
31 | source `dirname $0`/sourcefile
|
---|
32 | program=rename_rawfiles
|
---|
33 |
|
---|
34 | scriptlog=$runlogpath/$program-$datetime.log
|
---|
35 | date >> $scriptlog 2>&1
|
---|
36 |
|
---|
37 | # check if script is already running
|
---|
38 | lockfile=$lockpath/lock-$program.txt
|
---|
39 | checklock >> $scriptlog 2>&1
|
---|
40 |
|
---|
41 | rawdatapath=/data/fromtape/muxdata
|
---|
42 |
|
---|
43 | # find raw files named after the new convention but having a 5 digit subrun number
|
---|
44 | files=`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
|
---|
47 | for file in ${files[@]}
|
---|
48 | do
|
---|
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
|
---|
62 | done
|
---|
63 |
|
---|
64 | rm -v $lockfile >> $scriptlog 2>&1
|
---|
65 |
|
---|