使用Windows命令提示符重命名多个文件

时间:2022-12-01 10:33:07

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?

我有几个名称格式为dbo.table_name.sql的文件,我想将它们重命名为table_name.1.tbl如何使用windows cmd提示符进行操作?

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

我试过ren * .sql * .1.tbl,但它只将它重命名为dbo.table_name.1.tbl仍然无法删除dbo。这里..也尝试过ren dbo。*。sql * .1.tbl仍然没有运气:(

1 个解决方案

#1


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

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

#1


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

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