Search code examples
windowscommand-linefile-renamebatch-rename

How to remove prefixes into files using the Windows command line


My files are x_name.png, x_something.png, x_somethingElse.png

How can I remove the "x_" prefix from all these files ?


Solution

  • I don't think you can do this with a single line, you'll need a basic batch file.

    @echo off
    setlocal enabledelayedexpansion
    for %%a in (x_*.*) do (
        set fname=%%a
        set fname=!fname:~2!
        ren "%%a" "!fname!"
    )