-
Notifications
You must be signed in to change notification settings - Fork 0
/
process_orig.sh
78 lines (69 loc) · 2.06 KB
/
process_orig.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
#Usage: process.sh subjID datePath posFile
#set -x
subjID=$1
datePath=$2
posFile=$3
DsFiles=$(ls -d $datePath/*.ds | grep -v 'Noise')
logFile=$(ls $datePath/sessionLog*.txt)
#Find the date folder and update owner, group and access permissions
me=$(whoami)
chown -R $me:$me $datePath
chmod -R 775 $datePath
#Move the selected pos file and SessionLog to each of the .ds folders
for f in $DsFiles
do
# See if a pos file already exists
pos=$(ls $f/*.pos)
if [ -z "$pos" ]
then
# if the pos file does not have a matching subject ID,
# then prepend the ID while copying
posName=$(echo $(basename $posFile))
if [[ $posName == ${subjID}_* ]] ; then
echo "copying $posFile to ${datePath}/$f"
cp $posFile $f
else
echo "copying $posFile to ${datePath}/${f}/${subjID}_$posName"
cp $posFile ${f}/${subjID}_$posName
fi
else
echo "$pos already exists"
fi
# copy the SessionLog and prepend the ID
logName=$(echo $(basename $logFile))
echo "copying $logFile to ${f}/${subjID}_$logName"
cp -u $logFile ${f}/${subjID}_$logName
done
# copy the SessionLog and prepend the ID to the date folder
logName=$(echo $(basename $logFile))
echo "copying $logFile to ${datePath}/${subjID}_$logName"
mv $logFile ${datePath}/${subjID}_$logName
#Move the selected picture files to the dataset folder (datePath)
for f in "$@"
do
if [ -f "$f" ]&&[ "$posFile" != "$f" ]
then
fileName=$(echo $(basename $f))
echo "copying $f to ${datePath}/${subjID}_$fileName"
cp $f ${datePath}/${subjID}_$fileName
fi
done
#Check that all files have the subject ID
#extraFiles=$(ls -d $datePath/* | grep -v '.ds')
#for f in $extraFiles
#do
# echo "$f"
# fileName=$(echo $(basename $f))
# if [[ $fileName == ${subjID}_* ]] ; then
# echo "$f has subject ID"
# else
# fileName=$(echo $(basename $f))
# echo "copying $f to ${datePath}/${subjID}_$fileName"
# mv $f ${datePath}/${subjID}_$fileName
# fi
#done
# rename the folder
#folderName=$(echo $(basename $datePath))
#pathName=$(echo $(dirname $datePath))
#mv $datePath ${pathName}/${folderName}_$subjID