Last active
May 1, 2016 19:59
-
-
Save shedali/ceef1d914c05aa78f1c5 to your computer and use it in GitHub Desktop.
sort whatsapp to dated subfolders
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 | |
echo running; | |
find . -maxdepth 3 -regex ".*\-2016[0-9][0-9][0-9][0-9].*.*" | while read filename; | |
do | |
f=$(basename "$filename") | |
echo $f | |
date=$(echo "$f" | cut -c5-12) | |
echo $date | |
if echo "${date}" | grep '[0-9]' >/dev/null; then | |
dirpath='/Users/shedali/Dropbox/Events/2016/'${date:0:4}-${date:4:2}-${date:6:2} | |
echo makedir "$dirpath" | |
mkdir -p "$dirpath" | |
echo mo "$filename" ${dirpath} | |
mv "$filename" "${dirpath}" | |
else | |
echo 'Invalid input' | |
echo "${date}" | grep '[0-9]' | |
exit 1 | |
fi | |
done | |
# directory=${file%.pdf} | |
# mv "$filename" "$directory"/"$filename" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment