This PowerShell script will scan all files in the SourceDirectoryPath
and then move them into directories whose name is based on the file's LastWriteTime date.
Target directories will be created if they don't already exist, using a name based upon the specified TargetDirectoriesDateScope
, and they will be created within the TargetDirectoryPath
.
It is acceptable for the SourceDirectoryPath
and TargetDirectoryPath
to be the same directory path.
A common use-case of this script is to move photos into date-named directories based on when the photo was taken.
You can use the Invoke-MoveFilesIntoDateDirectories.ps1 script to easily provide parameters and run the cmdlet.
Some various files that were last updated on different dates:
The target directory containing the same files after the script ran and moved them into month date-named directories based on their LastWriteTime:
See what's changed in the application over time by viewing the changelog.
Buy deadlydog a hot apple cider for providing this script open source and for free :) Check out my GitHub sponsors if you would like to support my contribution by buying me a boba!