Skip to content

Instantly share code, notes, and snippets.

@guitarrapc
Last active March 12, 2018 03:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guitarrapc/20b90faba9459bc0245fd025206ee66d to your computer and use it in GitHub Desktop.
Save guitarrapc/20b90faba9459bc0245fd025206ee66d to your computer and use it in GitHub Desktop.
Change Extensions on PowerShell
# 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