Batch extended file rename

I am trying to rename every file that I have in a directory with an extra value based on the current directory list, so

------------------------- |-------------------------| | | B1S1A800.ext | | | B100M803.ext | | | B100N807.ext | | | B101S800.ext | | | B102S803.ext | ------------------------- 

Instead, it would look:

  ------------------------- |-------------------------| | | 1.ext | | | 2.ext | | | 3.ext | | | 4.ext | | | 5.ext | ------------------------- 

How can this be achieved in PowerShell?

+4
source share
1 answer

This is the way:

 $files = Get-ChildItem c:\yourpath\*.ext $id = 1 $files | foreach { Rename-Item -Path $_.fullname -NewName (($id++).tostring() + $_.extension) } 
+7
source

Source: https://habr.com/ru/post/1441005/


All Articles