2
votes

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 :(

1
ren can change the tail end of the filenames, but you'll need a for loop for the beginning. See the answers to stackoverflow.com/questions/9383032/batch-file-rename.Ryan Bemrose

1 Answers

0
votes

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"
)