If you survived last week’s mini-geek-fest, then this one may do you in! This is another script used in conjunction with the punctuation parser from last week that I use to manage my recording schedule.
It will ask for the text file you wish to manipulate and get the due date for the recording, then split that text file up into equal size chunks with sub-project due date for milestones that will keep you on a steady flow for completing the entire manuscript.
#!/bin/bash
clear
todaydate=$(date)
todayepoch=$(date +%s)
echo Today is $todaydate which is epoch $todayepoch
echo What file do you want to work on?
read textfile
echo What Project ID is this for?
read pid
touch $pid.sql
#get due date in mm/dd/yy
echo Due date in mm/dd/yy?
read duedate
duedate=”12/31/18″# convert to epoch
dueepoch=$(date +%s –date=$duedate)
print duedate and dueepoch
echo Due date is $duedate which is epoch $dueepoch
#calculate and print how many days, weeks, months to duedate
epochsleft=$(($dueepoch-$todayepoch))
echo $epochsleft “seconds left to finish.”
daysleft=$(($epochsleft/86400))
echo $daysleft “days left to finish.”
weeksleft=$(($daysleft/7))
chunks=$weeksleft #Default unless days overrides
milestoneratio=604800 #Ditto
echo $weeksleft “weeks left to finish.”
monthsleft=$(($weeksleft/4))
echo $monthsleft “months left to finish.”
if [ $daysleft -lt 14 ]; then echo Less than two weeks. Figuring by day.; chunks=$daysleft ; milestoneratio=86400 ;
elif [ $weeksleft -lt 5 ]; then echo Less than one month. Figuring by weeks.; chunks=$weeksleft; milestoneratio=604800 ; fi
echo $chunks time chunks remaining.
echo $milestoneratio is your epoch length per chunk.
#get hours in book
totalwords=($(wc -w $textfile))
echo $totalwords total words in file
totallines=($(wc -l $textfile))
echo $totallines total lines in file.
#calc lines per day
linesperday=$(($totallines/$daysleft))
linesperweek=$((linesperday*7))
echo You need to do $linesperday lines every day and $linesperweek every week.
#calc lines per chunk
linesperchunk=$(($totallines/$chunks))
#calc and print weekly due dates
i=1
while [[ $i -le $chunks ]] #chunks replaced weeksleft for daily iterations
do
((milestone=$todayepoch+imilestoneratio)) #milestoneratio replaced 604800 for daily interations milestonedate=$(date +%D –date=@$milestone) ((milestoneline=i$linesperchunk)) #linesperchunk replaced linesperweek for daily
echo Week “$i” $milestonedate $milestoneline
echo Week “$i” $milestonedate $milestoneline >> $pid.sql
sed -i “${milestoneline} i Milestone ${i} You should be here by ${milestonedate}” $textfile
((i=i+1))
done
sed -i ‘/Milestone/{G;G;G;G;}’ $textfile
Categories: Business Development, Software