#!/bin/bash
##copyright@Jason
##Path
DATE=`date +%Y-%m-%d`
##read
echo -en "Enter the absolute path to the directory you want to create: "
read dir
#if Statement to determine
if [ -z $dir ];then
exit 1;
else
## Loop to create a directory structure
for i in "$DATE"
do
Year=`echo $i|awk -F "-" '{print $1}'`
Month=`echo $i|awk -F "-" '{print $2}'`
Dieser_day=`cal|sed -n '7p'|awk '{print $NF}'`
## Determine whether there is in this directory
if [ -d $dir/$Year ];then
echo " "
echo "Warning:"
echo "This directory has been created!"
exit 1;
fi
mkdir $dir/$Year
## Create two directories
for month in `seq $Month 12`
do
mkdir $dir/$Year/$month
## Create three directory
for day in `seq 1 $Dieser_day`
mkdir $dir/$Year/$month/$day
for hour in `seq 0 23`
mkdir $dir/$Year/$month/$day/$hour
done
done
done
done