-
Notifications
You must be signed in to change notification settings - Fork 0
/
mkproj.sh
executable file
·69 lines (53 loc) · 1.87 KB
/
mkproj.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
#!/bin/bash
# This script creates a new project directory structure
#
# Matthew Giarra
# 2015-03-24
# Test number of input arguments. If less than one,
# then prompt the user for the name of the new project.
if [ "$#" -ne 1 ]; then
# Read project name from command line input.
read -p "Enter the desired path to the new project directory: " PROJECT_PARENT_DIR
# Check if no response was entered
# and exit if that's the case
if [ -z $PROJECT_PARENT_DIR ]; then
echo "No project path entered. Exiting."
exit 1
fi
else
# Assign the project name as the first input argument
PROJECT_PARENT_DIR=$1
fi
# If the project folder exists, then inform the user and exit.
if [ -d $PROJECT_PARENT_DIR ]; then
echo Directory already exists at $PROJECT_PARENT_DIR. Exiting.
exit 1
fi
# Confirm that the user wants to make the project folder.
read -r -p "Create new project folder at $PROJECT_PARENT_DIR? [y/N] " response
# Check if a positive "yes" response was entered.
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]
then
# Inform the user that a new project structure is being created.
echo Creating new project directory structure at $PROJECT_PARENT_DIR
# Create the analysis directories
mkdir -p ${PROJECT_PARENT_DIR%%/}/analysis/src
mkdir -p ${PROJECT_PARENT_DIR%%/}/analysis/data
# Literature directory
mkdir -p ${PROJECT_PARENT_DIR%%/}/literature
# Results directory
mkdir -p ${PROJECT_PARENT_DIR%%/}/results/figures
mkdir -p ${PROJECT_PARENT_DIR%%/}/results/videos
# Presentations directory
mkdir -p ${PROJECT_PARENT_DIR%%/}/presentations
# Manuscript directory
mkdir -p ${PROJECT_PARENT_DIR%%/}/manuscripts
# Modify the permissions of the new
# directory to give write and execute/search
# permissions to the group
chmod -R g+wx $PROJECT_PARENT_DIR
else
# Inform the user that nothing is happening.
echo Aborting. No action taken.
fi