Skip to content

Commit ab4a613

Browse files
committed
feature list added in readme
1 parent ab44697 commit ab4a613

File tree

2 files changed

+65
-37
lines changed

2 files changed

+65
-37
lines changed

README.md

+28
Original file line numberDiff line numberDiff line change
@@ -1 +1,29 @@
11
# File-Modification-Detector
2+
3+
## Installation
4+
- Directly excecute script in terminal in folder you want to monitor
5+
- Some functions require `sudo`
6+
7+
## Warnings
8+
- This program is currently under development. Provides no guarantee. You are responsible for safety of your own data.
9+
- Rename function renames batch files (beta)
10+
**(Always backup before performing this operation**
11+
**Use proper syntax)**
12+
13+
## Options/Functions
14+
1. Generates list of md5sums
15+
1. Recursive mode
16+
**multiple recursive**
17+
1. File/folder exclude mode
18+
**multiple exclude**
19+
1. graphical mode
20+
1. colored output
21+
1. logging
22+
1. batch rename
23+
1. prefix
24+
1. midfix
25+
1. suffix
26+
1. by date time
27+
1. comparison of last two md5sums
28+
1. shows modified files
29+
1. deleted/new files

filemoddetect.sh

+37-37
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ function about
1515
echo -e "\e[0K\r" "\e[38;5;${i}m\t\t\tWritten by Soham Bagayatkar\e[0m";
1616
echo -en "\e[1A";
1717
sleep .05;
18-
done;
18+
done;
1919
echo
2020
echo -en "\e[1A";
2121
echo -e "\e[0K\r";
2222
}
2323
function usage
2424
{
2525
cat << EOF
26-
Usage:
26+
Usage:
2727
filemoddetect [OPTION...] [FILE...] - File Modification Detector
2828
2929
Help Options:
@@ -119,7 +119,7 @@ if [ $colmode = true ]; then
119119
lblue='\033[1;34m'; purple='\033[0;35m'; lpurple='\033[1;35m'
120120
cyan='\033[0;36m'; lcyan='\033[1;36m'; lgray='\033[0;37m'
121121
white='\033[1;37m';
122-
122+
123123
fg_black=$(tput setaf 0); fg_red=$(tput setaf 1); fg_green=$(tput setaf 2)
124124
fg_yellow=$(tput setaf 3); fg_blue=$(tput setaf 4); fg_magenta=$(tput setaf 5)
125125
fg_cyan=$(tput setaf 6); fg_white=$(tput setaf 7)
@@ -130,7 +130,7 @@ if [ $colmode = true ]; then
130130
fi
131131
nc='\033[0m' # No Color
132132
revcol=$(tput rev)
133-
133+
134134
blink=$(tput blink); bold=$(tput bold); dim=$(tput dim); nc=$(tput sgr0)
135135
defforcol=$(tput setaf sgr9); defbackcol=$(tput setab sgr9)
136136

@@ -209,7 +209,7 @@ if [ "$1" != "" ]; then
209209
-e | --exclude=* )
210210
if [[ $1 = "--exclude="* ]]; then
211211
te=$1; te=${te:10}
212-
excludefile+=(`readlink -f "$te"`); excludeon=true
212+
excludefile+=(`readlink -f "$te"`); excludeon=true
213213
echo -e "\nExcluding file/directory: ${excludefile[-1]}\n"
214214
else
215215
if [[ -z $2 ]]; then
@@ -256,7 +256,7 @@ if [ "$1" != "" ]; then
256256
fi
257257
done
258258
fi
259-
unset $IFS #or IFS=$' \t\n'
259+
unset $IFS #or IFS=$' \t\n'
260260

261261
if [[ $excludeon = true ]]; then
262262
unset excludefile[0]
@@ -272,7 +272,7 @@ printf "\nCurrent directory $filepath\n\n"
272272

273273
if [[ $logmode = true ]]; then
274274
logat=$(date +"%m-%d-%y--%T")
275-
echo -e "${logat}\t\tCurrent directory $filepath" >> $logname
275+
echo -e "${logat}\t\tCurrent directory $filepath" >> $logname
276276
fi
277277

278278
if [ $optionerror = true ]; then
@@ -282,7 +282,7 @@ fi
282282
if [ $colmode = false ]; then
283283
black=''; dgray=''; red=''; lred=''; green=''; lgreen=''; brownorange=''; yellow=''; blue='';
284284
lblue=''; purple=''; lpurple=''; cyan=''; lcyan=''; lgray='' white='';
285-
285+
286286
fg_black=''; fg_red=''; fg_green=''
287287
fg_yellow=''; fg_blue=''; fg_magenta=''
288288
fg_cyan=''; fg_white=''
@@ -295,7 +295,7 @@ fi
295295
#check size
296296
if [[ -d $filepath ]]; then
297297
if [ -r $filepath ]; then
298-
if [[ $recmode == true ]]; then
298+
if [[ $recmode == true ]]; then
299299
CHECK="`du -hs $filepath | cut -f1`"
300300
else
301301
CHECK="`find $filepath -maxdepth 1 -type f -printf "%s + " | dc -e0 -f- -ep`"
@@ -340,7 +340,7 @@ if [[ $excludeon = true && $recmode == false ]]; then #if this condition then ma
340340
fi
341341
fi
342342
fi
343-
343+
344344
else
345345
if [[ $excludeon = true ]]; then
346346
if (( ${#excludefile[@]} < 2 )); then
@@ -380,10 +380,10 @@ fi
380380
# echo -en "${green}${bold}${#files[@]}$nc files found ~ $lblue$bold$CHECK$nc & ${bold}${yellow}${directs}${nc} directories";
381381
if [[ "${directs}" == "0" && "${#files[@]}" == "0" ]]; then
382382
echo -e "Nothing found!";
383-
383+
384384
if [[ $logmode = true ]]; then
385385
logat=$(date +"%m-%d-%y--%T")
386-
echo -e "${logat}\t\tNothing found!" >> $logname
386+
echo -e "${logat}\t\tNothing found!" >> $logname
387387
fi
388388
exit
389389
else
@@ -411,10 +411,10 @@ if [ $excludeon = true ]; then
411411
unset $IFS #or IFS=$' \t\n'
412412
else
413413
echo -e "Directory '$exc' has not given ${brownorange}read${nc} permission! (Try using sudo)"
414-
414+
415415
if [[ $logmode = true ]]; then
416416
logat=$(date +"%m-%d-%y--%T")
417-
echo -e "${logat}\t\tDirectory '$exc' has not given read permission! (Try using sudo)" >> $logname
417+
echo -e "${logat}\t\tDirectory '$exc' has not given read permission! (Try using sudo)" >> $logname
418418
fi
419419
exit
420420
fi
@@ -428,7 +428,7 @@ if [ $excludeon = true ]; then
428428
echo -e "File '$exc' has not given ${brownorange}read${nc} permission! (Try using sudo)"
429429
if [[ $logmode = true ]]; then
430430
logat=$(date +"%m-%d-%y--%T")
431-
echo -e "${logat}\t\tFile '$exc' has not given read permission! (Try using sudo)}" >> $logname
431+
echo -e "${logat}\t\tFile '$exc' has not given read permission! (Try using sudo)}" >> $logname
432432
fi
433433
exit
434434
fi
@@ -440,7 +440,7 @@ if [ $excludeon = true ]; then
440440
fi
441441
exit
442442
fi
443-
443+
444444
if [[ $failedbyfirst = true ]]; then
445445
arrtemp=()
446446
for i in "${files[@]}"; do
@@ -457,13 +457,13 @@ if [ $excludeon = true ]; then
457457
echo "Excluding file/directory $exc is $excludelen in size."
458458
if [[ $logmode = true ]]; then
459459
logat=$(date +"%m-%d-%y--%T")
460-
echo -e "${logat}\t\tExcluding file/directory $exc is $excludelen in size." >> $logname
460+
echo -e "${logat}\t\tExcluding file/directory $exc is $excludelen in size." >> $logname
461461
fi
462462
fi
463463
done
464464
fi
465465

466-
title="Choose one of the following option"
466+
title="Choose one of the following option"
467467
#printf "%*s\n" $(((${#title}+$COL)/2)) "$title"
468468
echo
469469
centerQ "$title"
@@ -529,7 +529,7 @@ else
529529
echo -e "${lred}Invalid response!${nc}"
530530
if [[ $logmode = true ]]; then
531531
logat=$(date +"%m-%d-%y--%T")
532-
echo -e "${logat}\t\tInvalid response!" >> $logname
532+
echo -e "${logat}\t\tInvalid response!" >> $logname
533533
fi
534534
fi
535535

@@ -542,7 +542,7 @@ if [[ $checkmd = "scan" ]]; then
542542
else
543543
echo "Creating md5sums..."
544544
fi
545-
545+
546546
if [[ $logmode = true ]]; then
547547
logat=$(date +"%m-%d-%y--%T")
548548
if [[ $renamemode = true ]]; then
@@ -552,19 +552,19 @@ if [[ $checkmd = "scan" ]]; then
552552
fi
553553
echo >> $logname
554554
fi
555-
555+
556556
filename="$filepath/md5sum$now.txt"
557557
num=1; i=0; errorocc=0; donesize=0
558558
# declare -i totsize; declare -i donesize
559-
# totsize=`du -sb ${files[@] | cut -f1`;
559+
# totsize=`du -sb ${files[@] | cut -f1`;
560560

561561
if [[ ( $failedbyfirst = false && ${#excludefile[@]} > 1 ) || ( $failedbyfirst = true && ${#excludefile[@]} > 0 ) ]]; then
562562
# elif [[ $failedbyfirst = true && ${#excludefile[@]} > 0 ]]; then
563563
for j in "${excludefile[@]}"; do
564-
echo "Skipping .... $j"
564+
echo "Skipping .... $j"
565565
if [[ $logmode = true ]]; then
566566
logat=$(date +"%m-%d-%y--%T")
567-
echo -e "${logat}\t\tSkipping .... $j" >> $logname
567+
echo -e "${logat}\t\tSkipping .... $j" >> $logname
568568
echo >> $logname
569569
fi
570570
done
@@ -579,7 +579,7 @@ if [[ $checkmd = "scan" ]]; then
579579
echo -e "${lred}File $i does not exist!${nc}"
580580
if [[ $logmode = true ]]; then
581581
logat=$(date +"%m-%d-%y--%T")
582-
echo -e "${logat}\t\tFile $i does not exist!" >> $logname
582+
echo -e "${logat}\t\tFile $i does not exist!" >> $logname
583583
fi
584584
fi
585585
done
@@ -610,7 +610,7 @@ if [[ $checkmd = "scan" ]]; then
610610
echo -e "\r${lred}Cancelled......${nc} @ ${percent}%\n\n"
611611
if [[ $logmode = true ]]; then
612612
logat=$(date +"%m-%d-%y--%T")
613-
echo -e "${logat}\t\tCancelled......" >> $logname
613+
echo -e "${logat}\t\tCancelled......" >> $logname
614614
fi
615615
temptime2=`date +%s`
616616
temptime=$(($temptime2 - $temptime))
@@ -621,7 +621,7 @@ if [[ $checkmd = "scan" ]]; then
621621

622622
if [[ $logmode = true ]]; then
623623
logat=$(date +"%m-%d-%y--%T")
624-
echo -e "${logat}\t\tResumed......" >> $logname
624+
echo -e "${logat}\t\tResumed......" >> $logname
625625

626626
if [[ $renamemode = true ]]; then
627627
echo -e "${lred}Last renaming of ${files[$((num-1))]} is failed!........${nc} (Reason: Due to inturruption)" 2>&1 | tee -a $logname
@@ -633,11 +633,11 @@ if [[ $checkmd = "scan" ]]; then
633633

634634
else
635635
if [[ $renamemode = true ]]; then
636-
echo -e "${lred}Last renaming of ${files[$((num-1))]} is failed!........${nc} (Reason: Due to inturruption)"
637-
echo -e "${lcyan}Renaming last file........${nc}"
636+
echo -e "${lred}Last renaming of ${files[$((num-1))]} is failed!........${nc} (Reason: Due to inturruption)"
637+
echo -e "${lcyan}Renaming last file........${nc}"
638638
else
639-
echo -e "${lred}Last md5sum calculation of ${files[$((num-1))]} is failed!........${nc} (Reason: Due to inturruption)"
640-
echo -e "${lcyan}Recalculating last md5sum........${nc}"
639+
echo -e "${lred}Last md5sum calculation of ${files[$((num-1))]} is failed!........${nc} (Reason: Due to inturruption)"
640+
echo -e "${lcyan}Recalculating last md5sum........${nc}"
641641
fi
642642

643643
fi
@@ -658,7 +658,7 @@ if [[ $checkmd = "scan" ]]; then
658658
logat=$(date +"%m-%d-%y--%T")
659659
echo -e "${logat}\t\tProcessing.... ${files[num-1]}" >> $logname
660660
fi
661-
661+
662662
if [ -f ${files[num-1]} -a -r ${files[num-1]} ]; then
663663
cursize=`du -sb ${files[num-1]} | cut -f1`
664664
if [[ $renamemode = true ]]; then
@@ -698,7 +698,7 @@ if [[ $checkmd = "scan" ]]; then
698698
echo -e "File ${files[num-1]} does not exist!"
699699
if [[ $logmode = true ]]; then
700700
logat=$(date +"%m-%d-%y--%T")
701-
echo -e "${logat}\t\tFile ${files[num-1]} does not exist!" >> $logname
701+
echo -e "${logat}\t\tFile ${files[num-1]} does not exist!" >> $logname
702702
fi
703703
((errorocc++))
704704
thisfilefailed=true
@@ -719,7 +719,7 @@ if [[ $checkmd = "scan" ]]; then
719719
if [[ $logmode = true ]]; then
720720
echo >> $logname
721721
fi
722-
722+
723723
if [[ $thisfilefailed = true ]]; then
724724
echo -e "\e[0K\r${lred}Processing of ${files[num-1]}${nc} failed!"
725725
if [[ $logmode = true ]]; then
@@ -738,7 +738,7 @@ if [[ $checkmd = "scan" ]]; then
738738
if [ "$canc" != "Y" ]; then
739739
# echo -en "\e[1A";
740740
if (( "$errorocc" > "0" )); then
741-
echo -e "\e[0K\rTotal ${yellow}"$((num-errorocc))"${nc} of ${#files[@]} processed. ${lred}${errorocc} failed!${nc}"
741+
echo -e "\e[0K\rTotal ${yellow}"$((num-errorocc))"${nc} of ${#files[@]} processed. ${lred}${errorocc} failed!${nc}"
742742
else
743743
echo -e "\e[0K\rTotal $num of ${#files[@]} processed."
744744
fi
@@ -760,7 +760,7 @@ if [[ $checkmd = "scan" ]]; then
760760
logat=$(date +"%m-%d-%y--%T")
761761
echo -e "${logat}\t\tGenerating grandmd5sum ...." >> $logname
762762
fi
763-
763+
764764
($( find $filepath -type f \( -name "md5sum*.txt" \) -exec md5sum {} + > $filepath/grandmd5sum$now.txt ))
765765
fi
766766
#files=(`find $filepath -type f \( -regextype sed -not -regex ${regex} \) `)
@@ -897,7 +897,7 @@ elif [[ $checkmd = "check" ]]; then
897897
echo
898898
done
899899
else
900-
echo "No files found for md5sum comparision."
900+
echo "No files found for md5sum comparison."
901901
fi
902902
# error_exit "$LINENO: An error has occurred."
903903
echo

0 commit comments

Comments
 (0)