Move files to specific directories based on file modified by date.

Copper Contributor

Hi All,

I'm trying to make sense of 1000's of photos and I'm looking for something a little different to the year - month standard option.
I'm trying to sort my pictures between specific dates for instance.

For example:
Pics from between 05-01-2000 & 04-02-2000 to be moved to directory 'Year 1\Month 0'
Pics from between 05-02-2000 & 04-03-2000 to be moved to directory 'Year 1\Month 1'
Pics from between 05-03-2000 & 04-04-2000 to be moved to directory 'Year 1\Month 2'
Pics from between 05-04-2000 & 04-05-2000 to be moved to directory 'Year 1\Month 3'

From searching i have found the following script



param (

Get-ChildItem -Path $SourceDirectory |
Where-Object {
    $_.LastWriteTime `
        -gt (Get-Date $ModifiedAfter) `
        -and $_.LastWriteTime -lt (Get-Date $ModifiedBefore) } |
ForEach-Object { $_ | Copy-Item -Destination $DestinationDirectory }



You then run it with



.\Copy-Files-Modified-Between-Dates `
    -SourceDirectory C:\Temp\all `
    -DestinationDirectory C:\Temp\subset `
    -ModifiedAfter '2000-01-05 18:00' `
    -ModifiedBefore '2000-02-04'



My question is how can this be made to increment onto the next month automatically or to reference a file for info maybe a csv or text file to say
Pics from between 05-04-2010 & 04-05-2010 to be moved to directory 'Year 10\Month 3'

0 Replies