summaryrefslogtreecommitdiff
path: root/dcimdirsort
blob: 5f5a7d17d4d855c44f946fa1cf8f983744335774 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh

if [ -z "$1" ]; then
	echo "Move files into a directory per day, based on file modification time"
	echo "usage: $0 file1 file2 ..."
	exit 0
fi

while [ ! -z "$1" ]; do
	file="$1"

	file_date=`date -r "${file}" +"%Y-%m-%d"`
	
	if [ ! -d "${file_date}" ]; then
		mkdir "${file_date}"
	fi

	echo "Moving ${file} to ${file_date}/"

	mv "${file}" "${file_date}/"

	shift
done