Last active
January 2, 2021 12:47
-
-
Save Denperidge/5608a5c265f65131a9bb936ade6b54b2 to your computer and use it in GitHub Desktop.
Prepend Date modified/LastWriteTime to all files in directory and subdirectories using Powershell 7 Core
This file contains 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
@echo off | |
REM Bat file intended to allow drag and drop of directories, as well as bypassing executionpolicy temporarily (instead of having to change it machine wide for a while) | |
pwsh -ExecutionPolicy Bypass -File "%~dp0prepend-date-recursive.ps1" "%1%" |
This file contains 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
$dir = $args | |
write-host $dir | |
$files = Get-ChildItem -Path "$dir" -Recurse -File | | |
Where-Object { -not $_.Name.Contains("__") } | | |
Rename-Item -NewName {$_.LastWriteTime.ToString("yyyyMMdd_HHmmss__") + $_.Name} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment