Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Need to rename files based on specific string within the current name

$
0
0

I have a large list of image files that look like:

78103OW-1-newcolor.jpg 

78103OW-1-sandind.jpg 

78103OW-2-sandind.jpg 

78103OW-3-sandind.jpg 

I want to move the color to the front of the string (and remove from the end).  Is there an easy way to do this?

I was initially thinking to move each individual color doing something like:

Get-ChildItem -Filter"*-sandind" | Rename-Item -NewName {"sandind" + $_.Name.Substring(0,$_.BaseName.length-8) + $_.Extension}

But that doesn't work either - nothing happens.

Any help would be appreciated!!


Viewing all articles
Browse latest Browse all 21975

Trending Articles



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