Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

Powershell Rename Script

$
0
0

Hello everyone,

I am working on trying to rename a bunch of files that will generally always have an underscore and a number (exp:  net_text_doc_01.pdf)

What I am trying to do is create a powershell script to remove everything from the underscore to the period so all you would have left is net_text_doc.pdf.  I have gotten this far with PS:

dir renaming | Rename-Item -NewName {$_.name -replace "_\d",""}

It works like you would think, but if the file has any other underscores followed by a number is removed.

Any thoughts on how i can get the end results i am looking for?  I am still fairly new when it comes to powershell so any and all help would be appreciated.


Viewing all articles
Browse latest Browse all 15370

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>