I recently created a Powershell script to add data to the end of invoice names that would add the phrase " - DOC #"
So an example would be 2017-05-25 INV 123456 and my script would make it 2017-05-25 INV 123456 - DOC 1
I am doing this for multiple invoices in a folder and they get numbered DOC 1-however many invoices there are. So if there are 20 invoices in a folder they would be DOC 1 - DOC 20.
Here is the script I am using:
$nr = 1
Dir | %{Rename-Item $_ -NewName ($_.BaseName + ' - DOC {0}' -f $nr++ + $_.Extension)}
ls
I now need to create a script to mass delete the the characters I have added from the end of the file name. But I want to keep the extension. Can someone help me with a script for this?
Thanks