自动给文件名增加前缀批处理

2024-11-17 18:46:30
推荐回答(2个)
回答(1):

==============================
@echo off
if not exist "F:\OK" md "F:\OK"
for %%I in ("F:\CP\*.txt") do (
copy "%%I" "F:\OK\2010_HH_%%~nI.txt"
)
rd /s /q "F:\CP"
md "F:\CP"
exit
==============================
上面是完成后:清空F:\cp文件夹下的所有内容

下面是完成后:清空F:\cp文件夹下的所有文本文档
==============================
@echo off
if not exist "F:\OK" md "F:\OK"
for %%I in ("F:\CP\*.txt") do (
move /y "%%I" "F:\OK\2010_HH_%%~nI.txt"
)
exit
==============================

回答(2):

@echo off
md F:\op
for /f "delims=" %%a in ('dir /b "F:\cp"') do (
copy /y "F:\cp\%%a" "F:\op\2010_HH_%%~nxa"
)
del /q /f F:\cp\*
pause

已修正