Created
April 14, 2023 09:44
-
-
Save otobrglez/88fae800a49b667e804a8253a29bd7e4 to your computer and use it in GitHub Desktop.
Recursively renaming files with PowerShell
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
# Oto Brglez - <otobrglez@gmail.com> | |
$folderPath = "dodo-was-here" | Resolve-Path | |
Get-ChildItem -Path $folderPath -Recurse -File | | |
ForEach-Object { | |
$newName = Join-Path (Split-Path $_.FullName) ` | |
-ChildPath ($_.FullName -replace $folderPath,'' -replace '/|\\','-' -replace '^(.)','') | |
Rename-Item -Path $_.FullName -NewName $newName -Force # -WhatIf | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment