Created
July 6, 2023 20:50
-
-
Save paulrobu/eac3c1abb4a739194152e62b847bdd10 to your computer and use it in GitHub Desktop.
Move photo files from current directory (e.g, Camera on Android phones) to newly created dated directories (e.g, 2023-07)
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
for f in *.jpg; do | |
#macos: | |
date=$(stat -f %Sm -t %Y-%m-%d "$f"); | |
#unix: | |
#date=$(date +%F -r "$f"); | |
y=${date:0:4}; | |
m=${date:5:2}; | |
new_dir="$y-$m"; | |
mkdir -p "$new_dir"; | |
mv "$f" "$new_dir"; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment