She who must be obeyed (my wife) has thousands of photos stored in a single pictures folder. She now realizes there is a better way and to get there would like to rationalize all the existing photos into individual folders based on photo creation date (yyyy-MM). She tells me the fix should be simple, so…
I have found the following script that should do what I want (but doesn’t):
Blockquote
$rootpath = ‘C:\Users\ABC\Pictures’
$files = Get-ChildItem $rootpath -File
foreach($file in $files) {
$foldername = $file.CreationTime.ToString(‘yyyy-MM’)
$topath = “$rootpath$foldername”
if(-not(Test-Path $topath -PathType Container)){
New-Item $topath -ItemType Directory
}
Move-Item $file.FullName $topath
} > Blockquote
The problem is that I have test run the scipt in different root folders with the same results, e.g., that only 2 subfolders are generated 2024-2, 2024-3, with pictures move into those folders.
I am stuck. Any help would be appreciated.
hip