Hunter的大杂烩 技术学习笔记

2024-07-23

windows cmd命令行下批量变更文件名

Filed under: 技术话题 — hunter @ 11:36 pm

for /f “delims=” %%a in (‘dir /b .‘) do (

call :find_dir %%~a

@if !ERRORLEVEL! == 0 (
set old_name=%%~a
set new_name=!old_name:~7,100!
@echo “!new_name!”
rename “!old_name!” “!new_name!”
) else (
@echo “%%~a”
)
)

exit /b

:find_dir variableName
@setlocal enableDelayedExpansion

@echo %1|>nul findstr /r “^1[26][0-9][0-9][0-9]” && set/a retV=0 || set/a retV=1
exit /b !retV!

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress