Simple powershell help

brandon20

Board Regular
Joined
Feb 12, 2014
Messages
203
Hi,

This isnt vba but.

I need to change multiple .txt file names in a folder.

I have found information about renaming the files using Powershell but I do not what to rename the file. I want to add an "_Deviation" to it.

I go into powershell and can get this far.

PS C:\Users\Brandon> cd "C:\Users|Brandon|Desktop|Deviation"
PS C:\Users|Brandon|Desktop|Deviation> Dir | Rename\Item -NewName { $_.name -replace " ",:_" }

What is in bold does not help me though. that is just how you can add a _ to where a space was.
I think I need a something other than the "Rename" command or whatever you call it.

I just need to know how to change the part that is in bold so that it will just add a "_Deviation" to the end of the file name

so it looks like this:

RA-0001_Deviation.txt

instead of RA-0001.txt

thanks for any help.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
I answered it.

PS C:\Users\Brandon> cd "C:\Users|Brandon|Desktop|Deviation"
PS C:\Users|Brandon|Desktop|Deviation> Dir | Rename-Item -NewName { $_.BaseName+"_Deviation" }
 
Upvote 0

Forum statistics

Threads
1,225,669
Messages
6,186,348
Members
453,350
Latest member
mjohnston819

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top