Last active
May 18, 2023 06:57
-
-
Save warderer/e62c7d04cffffd00d61bb1004692f728 to your computer and use it in GitHub Desktop.
[Rename PhotosVideos with Date - Time] Using Windows Terminal to Mass Rename all Files in a Folder with Date and Time #windows #photos #videos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - Windows Terminal Command to Rename all files in a folder with Year day month format and time using the last writted time (modified date) | |
| # Option #1 | |
| Get-ChildItem | Rename-Item -NewName {$_.LastWriteTime.ToString("yyyy-dd-MMM HH.mm.ss") + ($_.Extension)} | |
| # Option #2 | |
| Get-ChildItem | Rename-Item -NewName {$_.LastWriteTime.ToString("yyyy-MM-dd HH.mm.ss") + ($_.Extension)} | |
| - Windows Terminal Command to Rename all image files in a folder with Date of the taken time | |
| $shell = New-Object -ComObject shell.application | |
| $ukCulture = [Globalization.CultureInfo]'en-GB' | |
| Get-ChildItem | ForEach{ | |
| $folder = $shell.NameSpace($_.DirectoryName) | |
| $RawDate = ($folder.GetDetailsOf($folder.ParseName($_.Name),12) -Replace "[^\w /:]") | |
| $datetime = [DateTime]::Parse($RawDate,$ukCulture) | |
| $DateTaken = $datetime.ToString("yyyy-MM-dd HH.mm") | |
| Rename-Item $_.FullName ($DateTaken + $_.Extension)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment