Last active
March 12, 2018 03:53
-
-
Save guitarrapc/20b90faba9459bc0245fd025206ee66d to your computer and use it in GitHub Desktop.
Change Extensions on 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
# All Files | |
Get-ChildItem | where {-not $_.PSIsContainer} | %{Rename-Item -Path $_ -NewName ($_.BaseName + ".json")} | |
# Only .txt files | |
Get-ChildItem | where Extension -eq ".txt" | %{Rename-Item -Path $_ -NewName ($_.BaseName + ".json")} | |
# .NET | |
Get-ChildItem | where Extension -eq ".txt" | %{[PSCustomObject]@{Path=$_;NewName=[System.IO.Path]::ChangeExtension($_.FullName, ".json")}} | %{Rename-Item -Path $_.Path -NewName $_.NewName} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment