Tuesday, September 8, 2020

Setting up home NAS - Part 2 - PowerShell arrange media date bases files into YYYY\MM\DD folders

This is the third post in "Setting up home NAS". Other posts below

Setting up home NAS - Part 2 - PowerShell arrange media date bases files into YYYY\MM\DD folders (This post)

Background

This post is more about organizing and managing media files. Not about NAS specifically though this post is filed under the 'NAS' tag. As of writing this post, below is my setup and  I am happy
  • A router attached USB drive working as NAS. \\192.168.1.1\share. It is 1TB in size.
  • Sync the photos to my personal computer that has 500GB drive. SyncToy is working fine for on-demand sync
If you have a defined way and tools to organize the files, please skip this post.

Problem

One of the problems we are facing is the files from a variety of sources. We may have more than one camera, photos from social media such as WhatsApp, scanned old photos, etc...If we just label folders by event name or /oldphotos, /old1phots and /old2photos etc...it would be difficult in the future. So a better way is to arrange in folders based on the date taken
If we regularly move photos from all sources to our NAS device, it is easy we know what is the date and easily create and move to the right folders.
But, if we do it once in a month or two, it is difficult to put the files to the right folder.

Solution

There are GUI tools such as PhotoMove, Photos2Folders, or use IrfanView to move based on date. Even there is a command-line Exif tool to move the images bases on the modified date. But my media includes not only images, but it also has videos and audio files. Also, I may require a similar mechanism for other purposes in the future.

PowerShell to rescue

It may seem like overkill to write program to move files based on date. But I ended up coding PowerShell routine to do the same. Below goes the code. It's in gist

No comments: