Search code examples
windowsbatch-filecommand-promptfile-rename

Rename multiple files using windows command prompt


I have several files with the name format dbo.table_name.sql and i want to rename them into table_name.1.tbl how to do it using windows cmd prompt?

i have tried ren *.sql *.1.tbl but it only rename it to dbo.table_name.1.tbl still not able to remove dbo. here.. also tried ren dbo.*.sql *.1.tbl still not luck :(


Solution

  • A batch file like this would work.

    @echo off
    SETLOCAL EnableDelayedExpansion
    for %%F in (dbo*.sql) do (
    set "name=%%~nF"
    ren "!name!.sql" "!name:dbo.=!.tbl"
    )