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!
Credits 3,105 Posts 1,276 Joined 2008-03-08 13:00 18-year member UID 112398 Gender Male
Status Offline
First assume that all the jpg files and name.txt are placed in the d:\pic folder. For actual use, the OP can modify it himself:
@echo off&setlocal enabledelayedexpansion
set "n=-1"
for /f "delims=" %%i in ('dir /s /a-d /b d:\pic\*.jpg') do (
set /a n+=1&call :lp
ren "%%i" !str!
)
echo All done.&pause>nul&goto :eof
:lp
if %n% equ 0 (set "m=") else (set "m=skip=%n%")
for /f "%m% dielims=" %%i in (name.txt) do set "str=%%i"&goto :eof
Credits 2,404 Posts 946 Joined 2005-09-08 13:44 20-year member UID 42345
Status Offline
I wrote one, but I don't know whether duplicate filenames already exist. Back up first, then try it.
@echo off
for /f "tokens=*" %%i in ('dir /b /s /a-d *.jpg') do call:lp "%%i"
:lp
for /f "usebackq tokens=*" %%j in ("name.txt") do (
if not defined %%j set %%j=a&ren %1 "%%j"&goto :eof)
pause
Credits 2,362 Posts 1,133 Joined 2008-02-02 21:36 18-year member UID 110072 Gender Male
Status Offline
After coming to the DOS forum, I've found my head getting a lot bigger... Depressing, extremely depressing...
Every time I see this kind of question, I break out in a cold sweat...
Credits 6 Posts 3 Joined 2008-07-25 17:25 18-year member UID 122097 Gender Male
Status Offline
Originally posted by bat-zw at 2008-7-27 12:22 PM:
First assume that all the jpg files and name.txt are placed in the d:\pic folder. For actual use, the OP can modify it himself:
@echo off&setlocal enabledelayedexpansion
set "n=-1"
for /f "d ...
It says command syntax error, but thank you all the same!