Anyone know of a tool to fix the name of 1000 folders named by date incorrectly?

Will that single "d," in the middle of 'MMMM d, yyyy' work for 2 digit days? I'm still working on learning PowerShell.

Also can you explain, or point me to the reference for, the syntax used in that whole line? I get that "[datetime]" is a cast to that type, but that double colon and the reason for casting in the first place confuses me.

Of course, I'll admit that quite a bit of PowerShell syntax continues to elude me. It's worse, by far, than most regular expressions for my brain to parse.

Yes, as @trevm999 mentioned this is using .Net so will adhere to those standards where d is "The day of the month, from 1 through 31"
Custom date and time format strings | Microsoft Docs

Have to admit I stole and modified this line from StackOverflow but I'll try my best explaining it.

:: lets you call a static method from a class. So we are using it to call the parseexact method from the datetime class and passing in our parameters.

Code:
[datetime]::parseexact(1, 2, 3)
1 = The String to be parsed
2 = The expected format
3 = Can be used to set cultural info (en-GB, en-US etc). We don't need this so just set NULL.

One it's parsed as a valid datetime object we output back to a string using our preferred format with
Code:
.ToString('yyyy-MM-dd')
 
Another triumph of the US date-ordering system.

Search for everything containing "2007" and then drag all the matching folders (not the files) into a folder somewhere else called "2007".
Repeat for other years - it'll take about a minute per year, so maybe fifteen minutes in total.

If you need finer granularity the you can do the same for the contents of each of the new folders but sorting by month instead - this'll be quicker because the alphabetic sort by month works in your favour. Say five minutes per folder, so about an hour.

Done.

No tools needed, except the willingness to sacrifice a bit of time to doing it by hand.

THIS ... simple and smart, my brain just wasn't working when I was trying to figure this one out ... Your method is super simple!
 
Back
Top