China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-11 14:03
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to add a duplicate-name check and rename files during a batch distribution process View 686 Replies 0
Original Poster Posted 2009-03-11 12:03 ·  中国 广东 深圳 宝安区 电信
新手上路
Credits 3
Posts 3
Joined 2009-03-05 14:37
17-year member
UID 140716
Gender Male
Status Offline
cd /d "F:\test\"
for /f "delims=" %%a in ('dir /s /a-d /b E:\move\LVU-*.jpg') do (
for /f "delims=_" %%i in ("%%~na") do (
move /y "%%a" F:\tes
)
)

How do I check here whether there is already a JPG file with the same name in the F:\test\ directory, and if there is, rename it before distributing it? For example: both F:\test\ and E:\move\ have LVU-001_1.jpg. After running it, the LVU-001_1.jpg in E:\move\ should be renamed to LVU-001_1(2).jpg and then distributed into the F:\test directory. In other words, after execution, F:\test\ should contain both the original LVU-001_1.jpg and the distributed LVU-001_1(2).jpg

QuestionING
Forum Jump: