2

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

Adriano Repetti
  • 65,416
  • 20
  • 137
  • 208
sharad
  • 43
  • 4
  • `ren` can change the tail end of the filenames, but you'll need a for loop for the beginning. See the answers to https://stackoverflow.com/questions/9383032/batch-file-rename. – Ryan Bemrose May 13 '15 at 16:01

1 Answers1

0

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

pathe3
  • 348
  • 2
  • 7