Last active
March 27, 2019 11:25
-
-
Save fintanmm/e44b5258a12b553fbfbd08d69435cd95 to your computer and use it in GitHub Desktop.
Finding info about files and directories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export project=$1 | |
export pathOfProject=$2 | |
mkdir -p "./$project" | |
# find data/B8493 -type f -printf '%h\n' | sort -u | |
echo "Empty Dirs" | |
find "$pathOfProject" -t empty -t d --exec echo {} >> $project/emptydirs.txt \; | |
echo "Dirs with Files" | |
find "$pathOfProject" -type f -printf '%h\n' -exec echo {} >> $project/dirsWithFiles.txt \; | |
echo "Count" | |
cat emptydirs.txt | wc -l | |
cat dirsWithFiles.txt | wc -l | |
echo "Illegal Chars" | |
find "$pathOfProject" -name "*[<>:\\|?*]*" -exec detox -n -v "{}" >> $project/illegal.chars.txt \; | |
echo "Files older than 7 years" | |
find "$pathOfProject" -type f -mtime +2555 -exec echo '{}' >> $project/filesOlderThan7yrs.txt \; | |
echo "Jpeg optimize" | |
find "$pathOfProject" -type f -iname "*.jpg" -exec jpegoptim -n -m70 -b {} >> $project/jpeg.progress.csv \; | |
echo "Png optimize" | |
find "$pathOfProject" -type f -iname "*.png" -exec optipng -o7 -preserve -simulate {} >> $project/progress.png.log \; | |
echo "Raw image files" | |
find "$pathOfProject" -type f -iname "*.CR2|*.cr3|*.dcs|*.dcr|*.drf|*.k25|*.kdc" -exec echo {} >> $project/rawImages.txt \; | |
echo "Files longer that 250 chars" | |
find "$pathOfProject" -regextype posix-egrep -regex '.{250,}' -exec echo {} >> $project/filesLongerThan250.txt \; | |
# File count for top level directories. | |
echo "Media files" | |
find "$pathOfProject" -type f -exec file -N -i -- {} + | sed -n 's!: video/[^:]*$!!p' | tee $project/mediaFiles.txt | |
while read -r line; do stat -c "%s, '%n'" "$line" >> $project/mediaFileSize.csv ; done < $project/mediaFiles.txt | |
# Files greater than 200 megs | |
echo "all Directories called 'New Folder'" | |
find "$pathOfProject" -type d -iname "New*Folder" >> $project/foldersWithNewFolder.txt | |
echo "File Count" | |
echo "count,\"Directory\"" > $project/filesInFolderCount.txt; | |
find "$pathOfProject" -maxdepth 20 -type d -print0 | while read -d '' -r dir; do | |
num=$(find "$dir" -ls | wc -l); | |
printf "%5d,'%s\n'" "$num" "$dir" >> $project/filesInFolderCount.txt; | |
done | |
wget https://raw.githubusercontent.com/soxofaan/duviz/master/duviz.py -O duviz.py | |
python duviz.py $pathOfProject >> $project/visualizeDiskSpaceUsage.txt | |
# if em | |
# """ | |
# We found that there were ${countEmpty} | |
# """ | |
# pdf markdown.md $project.pdf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment