-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgStudy_merge.sh
executable file
·58 lines (42 loc) · 1.58 KB
/
gStudy_merge.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
#!/usr/bin/env bash
#
# Script to combine multiple packages downloaded from gStudy, when they contain
# data from the same study.
#
# Courtesy Allen T. Newton, 20211004
echo -e "\n\nWARNING: unzip the packages downloaded from gStudy *before* you proceed. If you need to cancel this script to do that, press [ctrl-c] now. \n\n"
echo -e "What directory contains the raw data folders downloaded from gStudy?"
read -e directory
echo -e "\n\n"
echo "======================================================"
echo "folders found in $directory:"
echo -e "\n"
ls -1 -d "${directory:-.}"*/
echo "======================================================"
echo -e "\n"
echo "Do you wish to merge all folders contained within: $directory?"
#read in a yes/no answer, and act accordingly
select yn in "Yes" "No"; do
case $yn in
#execute this code if the users confirms that they want to perform a merge
Yes )
#first, check to ensure that the input is a directory
if [[ -d "$directory" ]]
then
echo "$directory IS a directory."
else
echo "$directory IS NOT a directory. Aborting the merge operation..."
exit
fi
break;;
#gracefully exit if the user indicates that they DON'T want to perform a merge
No )
echo "Aborting merge operation because you selected 'No'. Have a great day!"
exit;;
esac
done
if [[ "$yn" == "Yes" ]]
then
echo "Preparing to merge sub-folders..."
ditto -V "$directory"/* "$directory"/merged/
fi