batch-file - 该文件已用批处理文件重命名,但不会停止
问题描述
我需要通过在文件名前添加“BV”来重命名文件夹中的所有文件。我的代码正在运行,但是当该文件夹中的文件总量超过 ca. 200 个文件。它将所有文件重命名为:“BV_BV_BV ...”并且它不会停止。
这是我的代码:
@echo off & setlocal
ECHO Moechten Sie das wirklich tun? (Bereits vorhandene Bildverzeichnisse werden geloescht
ECHO und in den Dateinamen wird AWK2 hinzugefuegt) (j / n)
SET /p wahl=
if '%wahl%' == 'n' goto Nein
if '%wahl%' == 'j' goto Ja
:Ja
ECHO on
FOR %%I IN (*.bmp) DO ren "%%I" BV_"%%~nI".bmp
pause
我不确定如何在重命名所有文件后停止批处理文件。谢谢你的帮助。
解决方案
假设您想重命名所有文件一次,前缀为循环BV_
中的示例。for
注意,我用choice
而不是set /p
@echo off & setlocal
ECHO Moechten Sie das wirklich tun? (Bereits vorhandene Bildverzeichnisse werden geloescht
ECHO und in den Dateinamen wird AWK2 hinzugefuegt) (j / n)
choice /c jn /m "wahl"
goto opt%errorlevel%
:opt1
for /f "delims=" %%I IN ('dir /b /a-d *.bmp ^| findstr /v /b "BV_"') do ren "%%~I" "BV_%%~I"
goto :eof
:opt2
echo do what ever you need to do here.
推荐阅读
- c# - CsvParser 错过了一些指定分隔符的地方
- javascript - 从 URL 中删除多个参数之一并在不删除参数的情况下刷新页面但使用其他参数
- node.js - Eslint 说 Typescript 应用程序中的所有枚举“已经在上层范围内声明”
- windows - 从 wmic.exe 调用中提取感兴趣的行
- c# - 从与服务器位于同一网络的另一台 PC 访问 MySQL 需要更长的时间
- r - 通过使用R来查找有多少成员连续填写了调查数据--R
- c# - 如果我在检查员父类中可见,如何查看子类的字段?
- java - Java Web 应用程序中的 WebLogic 和 Kerberos 票证
- php - PHP spl_autoload_register 不适用于使用功能导入
- javascript - 使用 setInterval 从 express 重新加载页面