Created
August 7, 2015 14:15
-
-
Save binki/fedfb1fb6a60a4efc607 to your computer and use it in GitHub Desktop.
Move workreceipts from OneDrive to where my employer wants them and fix the filename date.
This file contains hidden or 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 | |
for f in "${HOME}/OneDrive/IFTTT/iOS Photos/workreceipts/"*; do | |
if [ -e "${f}" ]; then | |
dspec=$(echo "${f##*/}" | sed -e 's/_/ /g' -e 's/\.[^.]*$//' -e 's/ at / /' -e 's/\([0-9][0-9]\)\([0-9]*[AP]M\)/\1:\2/') | |
# lol. Windows doesn’t allow colons in filenames. Guess why. | |
erf="${HOME}/Documents/SugarSync Shared Folders/Nathan Brink/expense_reports/$(date +%Y-%m --date "${dspec}")/$(date -Iseconds --date "${dspec}" | sed -e s/:/./g).${f##*.}" | |
mkdir -p "${erf%/*}" | |
mv "${f}" "${erf}" | |
else | |
true | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment