Search

Sorting Files into Years and Month

Updated: Jun 30

Thousands of files, no structure, let's get them organised into months and years 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 is 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 into 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 file names are amended to include an incremental number preventing potential loss of data with files overwriting each other.



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







8 views0 comments