Search

Sorting Files into Years and Month

Updated: Mar 28

Thousands of files, no structure, lets get them organised into month and year with PowerShell. Duplicates are moved to another directory for review.


This script was written in response to trying to manage the 10’s of thousands of photos and videos being uploaded to a file share each year. Management, near impossible with Synology’s DS Photo Android App automatically uploading new photo’s to the root of the share. Plus any taken with cameras or other mobiles were also dumped into the same share. A bit of a mess.


For the purposes of testing and this blog, a Data directory was created off the root of C:\. A few hundred photos and videos have been dumped… oops… copied in to the folder. The files were copied to create duplicates.


Download the 'hash and then sort by month' script from @ Tenaka/FileSystem (github.com)


Open PowerShell_ise and browse to the downloaded script.


Update the $path variable, Ctrl + A and then F8, sit back and wait for the files to be organised.

On a serious note, please don't run this without testing.


So what does it do:


All files are compared based on their file hash to find all duplicates.


Duplicate files names are amended to include an incremental number preventing potential loss of data with files over writing each other.



Files that aren't duplicates are moved based on their creation date to Year\Month directory.







6 views0 comments