2024-09-15 02:45:07 -04:00
|
|
|
<#
|
|
|
|
.SYNOPSIS
|
|
|
|
Renames files
|
|
|
|
|
|
|
|
Written by: Alexander Bobkov
|
|
|
|
Date: Sep 15, 2024
|
|
|
|
|
|
|
|
#>
|
|
|
|
|
|
|
|
# Script
|
2024-09-15 02:47:29 -04:00
|
|
|
# Specify path and original file extention
|
2024-09-15 02:45:07 -04:00
|
|
|
Get-ChildItem -Path . -Filter "*.txt" | forEach-Object {
|
2024-09-15 02:47:29 -04:00
|
|
|
# Change file extention from original to a new one
|
2024-09-15 02:45:07 -04:00
|
|
|
Rename-Item -Path $_.Name -NewName $_.Name.Replace("txt", "bat") -Verbose
|
2024-09-15 02:47:29 -04:00
|
|
|
# Output the name of file that was renamed
|
2024-09-15 02:45:07 -04:00
|
|
|
Write-Host $_.Name
|
|
|
|
}
|
|
|
|
|
|
|
|
# One-liner
|
|
|
|
#Get-ChildItem -Path . -Recurse -Include "*.txt" | Rename-Item -NewName { $_.Name -replace ".txt", ".bat" }
|