Organize the images and videos by date

This post will describe the steps to store your media files, like images and videos, organized by their creation date. This tool is beneficial for photography enthusiasts and professionals to keep track of their work.  


Prerequisite:

  1. bash
  2. ExifTool
  3. WSL(if on windows)

 

Important notes:
 
  • The steps provided here are tested by me on my home server, its lossless and work fine for me. However, I will not be responsible if you lose any of your content due to the procedure described in this post.  
  • My recommendation would be to backup your data at a separate location and then attempt using this tool.
  • Start with a smaller set of media files.
  • Always validate that the content before and after the usage of the tool is the same. This can be done by using “find -type f |wc -l” and repeating at the output location.
  • By default, the tool is looking for the following formats, but you can easily modify the file to add/remove any formats.
- png
- 3gp
- MOV
- m4v
- avi
- gif
- jpeg
- jpg
- mkv
- mpg
- bmp
- flv
- wmv
- mp4

 

 
  • The following formats are supported, I personally prefer the 2nd option:
The output structures are:
- YYYY
  |_MM
    |_DD
- YYYY |_MM
- YYYY

 

Pro vs cons

Procedure:

 
Steps-1:  Download the script from GitHub

If wget, is not present, You may open the link in the browser to download the file. 

 wget https://raw.githubusercontent.com/technekey/imageOrganizer/main/mediaOrganizer.sh
Step-2: Optionally, if you want to see the various flags supported by this script
bash mediaOrganizer.sh -h
Step-3: Provide the input directory, output directory, and the desired format
Syntax:
bash mediaOrganizer.sh -i INPUT_DIR_PATH -o OUTPUT_DIR_PATH -f FORMAT(one of YYYY, YYYYMM, YYYYMMDD)

Example: In the following example, all the media files in the ~/demo directory are moved under the ~/organized_media directory.

bash mediaOrganizer.sh -i ~/demo -o ~/organized_media -f YYYYMM
Mon May 2 01:31:57 PM CDT 2022: [Info]: The initial size of input directory(/home/technekey/demo) is 3.4G
Mon May 2 01:31:57 PM CDT 2022: [Info]: Processing 1/211 file. Current file is VID-20190618-WA0006.mp4
Mon May 2 01:31:57 PM CDT 2022: [Info]: Processing 2/211 file. Current file is VID-20190422-WA0017.mp4
Mon May 2 01:31:57 PM CDT 2022: [Info]: Processing 3/211 file. Current file is 20190704_213607.mp4
Mon May 2 01:31:57 PM CDT 2022: [Info]: Processing 4/211 file. Current file is VID-20191227-WA0004.mp4
...
.........
.............
Step-4: Results

Notice that few directories are created under the ~/organized_media directory. These directories(YEARS) are created based on the creation date of the files present in the input directories. 

ls -lrt ~/organized_media/
total 12
drwxrwxr-x 3 technekey technekey 4096 May 2 13:32 2022
drwxrwxr-x 3 technekey technekey 4096 May 2 13:32 2021
drwxrwxr-x 13 technekey technekey 4096 May 2 13:32 2019

Inside each directory for each year, there will be sub-directories created for each month, I have used YYYYMM as the desired format. If you use YYYYMMDD, then an additional directory will be created for each file creation date.

tree -f ~/organized_media/ 
/home/technekey/organized_media
├── /home/technekey/organized_media/2019
│   ├── /home/technekey/organized_media/2019/01
│   │   ├── /home/technekey/organized_media/2019/01/20190104_180215.mp4
│   │   └── /home/technekey/organized_media/2019/01/20190105_135919.mp4
│   ├── /home/technekey/organized_media/2019/03
│   │   ├── /home/technekey/organized_media/2019/03/VID-20190228-WA0061.mp4
│   │   ├── /home/technekey/organized_media/2019/03/VID-20190302-WA0056.mp4
│   │   └── /home/technekey/organized_media/2019/03/VID-20190330-WA0016.mp4
│   ├── /home/technekey/organized_media/2019/04
│   │   ├── /home/technekey/organized_media/2019/04/VID-20190403-WA0024.mp4
│   │   ├── /home/technekey/organized_media/2019/04/VID-20190406-WA0028.mp4
│   │   ├── /home/technekey/organized_media/2019/04/VID-20190422-WA0020.mp4
│   │   ├── /home/technekey/organized_media/2019/04/VID-20190424-WA0029.mp4
│   │   └── /home/technekey/organized_media/2019/04/VID-20190425-WA0055.mp4
│   ├── /home/technekey/organized_media/2019/05
│   │   ├── /home/technekey/organized_media/2019/05/20190525_183410.mp4
│   │   ├── /home/technekey/organized_media/2019/05/20190525_183631.mp4
│   │   ├── /home/technekey/organized_media/2019/05/VID-20190531-WA0010.mp4
│   │   └── /home/technekey/organized_media/2019/05/VID-20190531-WA0011.mp4
│   ├── /home/technekey/organized_media/2019/06
│   │   ├── /home/technekey/organized_media/2019/06/VID-20190604-WA0016.mp4
│   │   ├── /home/technekey/organized_media/2019/06/VID-20190630-WA0037.mp4
│   │   ├── /home/technekey/organized_media/2019/06/VID-20190630-WA0038.mp4
│   │   └── /home/technekey/organized_media/2019/06/VID-20200213-WA0005.mp4
│   ├── /home/technekey/organized_media/2019/07
│   │   ├── /home/technekey/organized_media/2019/07/20190704_213329_001.mp4
│   │   ├── /home/technekey/organized_media/2019/07/VID-20190728-WA0011.mp4
│   │   └── /home/technekey/organized_media/2019/07/VID-20190728-WA0017.mp4
│   ├── /home/technekey/organized_media/2019/08
│   │   ├── /home/technekey/organized_media/2019/08/20190829_174025.mp4
│   │   ├── /home/technekey/organized_media/2019/08/VID-20190824-WA0007.mp4
│   │   └── /home/technekey/organized_media/2019/08/VID-20190825-WA0016.mp4
│   ├── /home/technekey/organized_media/2019/09
│   │   ├── /home/technekey/organized_media/2019/09/2019_09_08_01_00_42_trim.mp4
│   │   ├── /home/technekey/organized_media/2019/09/VID-20190918-WA0059.mp4
│   │   ├── /home/technekey/organized_media/2019/09/VID-20190919-WA0049.mp4
│   │   └── /home/technekey/organized_media/2019/09/VID-20190930-WA0031.mp4
│   ├── /home/technekey/organized_media/2019/10
│   │   ├── /home/technekey/organized_media/2019/10/20191004_201042.mp4
│   │   ├── /home/technekey/organized_media/2019/10/VID-20191030-WA0035.mp4
│   │   └── /home/technekey/organized_media/2019/10/VID-20191104-WA0042.mp4
│   ├── /home/technekey/organized_media/2019/11
│   │   ├── /home/technekey/organized_media/2019/11/VID-20191117-WA0075.mp4
│   │   ├── /home/technekey/organized_media/2019/11/VID-20191130-WA0029.mp4
│   │   └── /home/technekey/organized_media/2019/11/VID-20191222-WA0008.mp4
│   └── /home/technekey/organized_media/2019/12
│   ├── /home/technekey/organized_media/2019/12/20191226_180645.mp4
│   └── /home/technekey/organized_media/2019/12/VID-20191229-WA0014.mp4
├── /home/technekey/organized_media/2021
│   └── /home/technekey/organized_media/2021/09
│   └── /home/technekey/organized_media/2021/09/VID-20210905-WA0023.mp4
└── /home/technekey/organized_media/2022
└── /home/technekey/organized_media/2022/01
└── /home/technekey/organized_media/2022/01/20220114_124943.mp4

 

16 directories, 211 files

0 0 votes
Please, Rate this post
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
Scroll to Top