I would like to solve this thema:
I have for example
.jpg files (1.jpg - n.jpg)
and
list.txt written as follows:
1¦name_1
2¦name_2
....
n¦name_n
I want to draw names from this list.txt file to single pictures (1.jpg annotate with name_1 and so on).
I tried to use this batch, but it reads just last name:
-------------------------------------------------------------
set %sc=0
for %%f in (*.jpg) do (
set /a %sc=sc+1
)
set %lv=0
:begin
set /a %lv=lv+1
for /f "delims=¦ tokens=2 skip=%lv%" %%A in (list.txt) do (convert -fill yellow -pointsize 20 -gravity south -draw "text 0,4 '%%A' " %lv%.jpg c%lv%.jpg)
if %lv% equ %sc% goto enddir
goto begin
:enddir
-------------------------------------------------------------
Can You help me?
Thanx
Michal
Batch - extracting names from file to draw
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
Re: Batch - extracting names from file to draw
When DOS reads your FOR statement it sets all the variable ONCE. You have to set delayed variable expansion so that it sets them each time through the loop and then eac hvariable that must be delayed must be enclosed in !..! instead of %..% (dontcha just love DOS batch syntax? )
Delayed expansion is turned on with this command:
SETLOCAL EnableDelayedExpansion
In your case I presume you will need to use !lv! in the loop instead of %lv%
Pete
Delayed expansion is turned on with this command:
SETLOCAL EnableDelayedExpansion
In your case I presume you will need to use !lv! in the loop instead of %lv%
Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
See my message in this topic for a link to a zip of all the files.
Re: Batch - extracting names from file to draw
Thank You Pete,
I found it! You gave me courage to test other ways, this one is running:
set %sc=0
for %%f in (*.jpg) do (
set /a %sc=sc+1
)
set %lv=0
:begin
set /a lv=lv+1
FOR /F "delims=¦ tokens=2 skip=%lv%" %%A in (list.txt) do (c -fill red -pointsize 20 -gravity south -draw "text 0,4 '%%A' " %lv%.jpg c%lv%.jpg
if %lv% equ %sc% goto enddir
goto begin
)
:enddir
Hours of time are saved..
Unfortunatelly I don’t manage Perl or something better than DOS :-/
Good Luck!
Michal
arboretum.mendelu.cz/rs/obrazek.pl?id=9942
I found it! You gave me courage to test other ways, this one is running:
set %sc=0
for %%f in (*.jpg) do (
set /a %sc=sc+1
)
set %lv=0
:begin
set /a lv=lv+1
FOR /F "delims=¦ tokens=2 skip=%lv%" %%A in (list.txt) do (c -fill red -pointsize 20 -gravity south -draw "text 0,4 '%%A' " %lv%.jpg c%lv%.jpg
if %lv% equ %sc% goto enddir
goto begin
)
:enddir
Hours of time are saved..
Unfortunatelly I don’t manage Perl or something better than DOS :-/
Good Luck!
Michal
arboretum.mendelu.cz/rs/obrazek.pl?id=9942