Repository navigation
Expand file tree
/
Copy pathcopyDirectories.sh
More file actions
executable file
·86 lines (76 loc) · 1.57 KB
/
Copy pathcopyDirectories.sh
File metadata and controls
executable file
·86 lines (76 loc) · 1.57 KB
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
79
80
81
82
83
84
85
86
#!/bin/bash
usage()
{
cat << EOF
usage: $0 options
This script will copy the directory structure of one folder to another folder.
OPTIONS:
-h Show this message
-s The absolute path to the source folder
-d The absolute path to the destination folder
-f Copy the sh and jdl files as well
-v Verbose
EOF
}
while getopts “hs:d:fv” OPTION
do
case $OPTION in
h|\?)
usage
exit 1
;;
s)
if [[ "$1" = /* ]]
then
source=$OPTARG
else
source=$PWD/$OPTARG
fi
;;
d)
if [[ "$1" = /* ]]
then
destination=$OPTARG
else
destination=$PWD/$OPTARG
fi
;;
f)
files=true
;;
v)
VERBOSE=" -print "
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
if [ -z "$source" ]
then
echo -e "\nsource is empty"
exit 1
else
echo -e "\nsource = $source"
fi
if [ -z "$destination" ]
then
echo -e "\ndestination is empy"
exit 1
else
echo -e "\ndestination = $destination"
fi
cd $source &&
find . -type d $VERBOSE -exec mkdir -p -- $destination/{} \;
if [ $files ]
then
find . -type f -name "*.jdl" $VERBOSE -exec cp {} $destination/{} \;
find . -type f -name "*.sh" $VERBOSE -exec cp {} $destination/{} \;
fi
echo -e "\nDONE\n"
#You could do something like:
#find . -type d >dirs.txt
#to create the list of directories, then
#xargs mkdir -p <dirs.txt
#to create the directories on the destination.