Hi @JOSÉ LUÍS DE BRITO CARDOSO ,
please try this:
$number = 0
ls | %{Rename-Item $_ "$number$($_.Extension)"; $number++}
Just compare this and your approach. It's just a matter of syntax.
Btw.: Your code might look shorter but is bascically the same:
ls
is an alias of Get-ChildItem
%
is an alias of Foreach-Object
----------
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards
Andreas Baumgarten