1 Star 0 Fork 0

CheriSh_Meng/kemu14_wx_new

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
rename_files.bat.bak 1.01 KB
一键复制 编辑 原始数据 按行查看 历史
CheriSh_Meng 提交于 2024-12-12 22:27 +08:00 . [add] 抖音小程序迁移
@echo off
setlocal enabledelayedexpansion
:: 获取脚本所在的目录
set "scriptDir=%~dp0"
:: 检查是否有 .ttml 文件存在
set "foundFiles=0"
for /r "%scriptDir%" %%f in (*.ttml) do (
set /a foundFiles+=1
)
if %foundFiles% equ 0 (
echo No .ttml files found in the directory and its subdirectories.
pause
exit /b
)
:: 递归遍历脚本所在目录及其子目录中的所有 .ttml 文件
for /r "%scriptDir%" %%f in (*.ttml) do (
set "fullPath=%%f"
set "newPath=%%~dpnf.wxml" :: 构造新的路径和文件名(去掉原来的.ttml扩展名)
:: 输出调试信息
echo Processing file: %%f
echo New name will be: !newPath!
:: 检查新文件名是否已经存在,避免覆盖
if not exist "!newPath!" (
ren "%%f" "%%~nxf:~0,-5.wxml" :: 去掉原扩展名再添加新扩展名 (.ttml是5个字符)
if errorlevel 1 (
echo Failed to rename: "%%f"
) else (
echo Renamed: "%%f" to "%%~nxf:~0,-5.wxml"
)
) else (
echo Skipped renaming: "%%f" because "!newPath!" already exists.
)
)
endlocal
pause
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/pingm/kemu14_wx_new.git
git@gitee.com:pingm/kemu14_wx_new.git
pingm
kemu14_wx_new
kemu14_wx_new
master

搜索帮助