E
E
Eugene2014-08-24 17:33:50
linux
Eugene, 2014-08-24 17:33:50

How to sort files in directories by date?

There is a system with Debian on board, a camera is connected. Motion in the presence of movement in the directory / home / user / motion_files removes jpg with a certain frame rate. It is necessary to sort files in such a way that folders are created in the current directory: /home/user/motion_files/files/(year)/(month)/(date)/
And *.jpg files are sorted accordingly.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
arthurchumak, 2014-08-24
@Jek_Rock

move.sh

path=/home/user/motion_files/files/$(date +%y -r $1)/$(date +%m -r $1h)/$(date +%d -r $1)
mkdir -p $path
mv $1 $path

find.sh
find -name *.jpg -exec move.sh {} \;

T
tsarevfs, 2014-08-24
@tsarevfs

The bash or python daemon picks up files and scatters them into folders.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question