2

I have a folder containing only images:

1.png
2.png
...
11000.png

I want to rename these files, adding a p as follows:

p1.png
p2.png
...
p11000.png

How can I achieve this, as I've tried the following, but it's not working:

Ren *.png ???p.*
JW0914
  • 7,052
  • 7
  • 27
  • 48
  • You asked for a command to do it, but you might like to know about [PowerRename](https://github.com/microsoft/PowerToys/wiki/PowerRename-Overview) as an option in Windows Explorer. – Andrew Morton Jul 28 '20 at 15:05
  • 3
    Does this answer your question? [Windows rename multiple files](https://superuser.com/questions/1459634/windows-rename-multiple-files) – Andrew Morton Jul 28 '20 at 15:48

2 Answers2

4

Try using ren:

Ren "*.png" "p*.png"
for %i in ("c:\your\folder\*.png")do ren "%~i" "p%~nxi"

rem :: in bat file: 
for %%i in ("c:\your\folder\*.png")do ren "%%~i" "p%%~nxi"
  • In PowerShell:
get-item c:\your\folder\*.png | ren -newname {"p"+$_.name}
  • Or PowerShell in cmd:
powershell -nop -c "Get-Item 'c:\your\folder\*.png' | ren -newname {'p'+$_.name}"
Io-oI
  • 7,588
  • 3
  • 12
  • 41
4

Try this using Powershell:

Get-ChildItem "Filepath" -Filter *.png | Rename-Item -Newname {"p" + $_.name}

Short style:

Ls "Filepath" -filter *.png | Ren -newname {"p"+$_.name}

A bit longer batch style:

@cd "Filepath" & @for %%a in (*.png) do Ren "%%~nxa" "p%%~nxa"
JW0914
  • 7,052
  • 7
  • 27
  • 48
Wasif
  • 7,984
  • 2
  • 19
  • 32