|March 15, 2017|
This is a simple BASH script that I used to sort a folder that has a lot of images. I wanted to put photos in a folder based on the date it was created.
This script will work in any environment, but I wrote this specifically to handle a large set of photos in a folder on my Macintosh.
#!/bin/bash for f in *; do dir=$(stat -f%SB -t%Y-%m-%d "$f") echo $f '->' $dir [ -d "$dir" ] || mkdir "$dir" mv "$f" "$dir"/ done
Create a file with the above content. I call my file sort.sh. Move the file to any directory that you want to clean up. To execute, simply type in:
In a few minutes you'll see the contents of the folder be replace with a bunch of date folders. (Yes even the sort.sh file will get moved to a folder.)
Feel free to leave a comment about this post.