I have files that are generated every morning:
I would like to rename the files:
I would basically be replacing Default
with VOD
.
I am using Powershell 1.0. Any help would be greatly appreciated.
In Windows PowerShell, go to a file folder, enter dir | rename-item -NewName {$_.name -replace “My”,”Our”} and press Enter.
You can call the PowerShell replace method on any string to replace any literal string with another. If the string-to-be-replaced isn't found, the replace() method returns nothing. You don't need to assign a string to a variable to replace text in a string.
For example, the command ls lists the directory content in Linux and macOS. Running the ls alias in PowerShell on Windows calls the PowerShell command Get-ChildItem.
simplified:
ls *.csv | Rename-Item -NewName {$_.name -replace "Default","VOD"}
I do not have PowerShell 1.0 to test, but assuming you are running this in the folder where files reside, you can try:
Get-ChildItem Default_*.csv |Rename-Item -NewName {$_.name -replace '^Default','VOD'}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With