how to write a program?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
david98
Posts: 1
Joined: 24 Apr 2019 05:19

how to write a program?

#1 Post by david98 » 24 Apr 2019 05:25

I need rename the files
710f7fa45c6911e9648d2cfda1bf577d.jpg
cde9bde81a5b11e96b882cfda1bf577d.jpg
2af8db480fca11e71a9a141877341409.jpg
in the article, taking the article from the namefile.txt file by name and get 020701BT.jpg
040109GT.jpg
it is also necessary that for the picture cde9bde81a5b11e96b882cfda1bf577d.jpg the name was obtained by adding the article 020701BT plus 1
and for the picture d266b9021a5b11e96b882cfda1bf577d.jpg the name was obtained by adding the article 020701BT plus 2
As a result we get 020701BT1.jpg and 020701BT2.jpg
file namefile.txt attached below
<Article>020701BT</Article>
<Picture> 71 / 710f7fa45c6911e9648d2cfda1bf577d </ Picture>
<Picture> cd / cde9bde81a5b11e96b882cfda1bf577d </ Picture>
<Picture> d2 / d266b9021a5b11e96b882cfda1bf577d </ Picture>
<Article> 040109GT </ Article>
<Picture> 2a / 2af8db480fca11e71a9a141877341409 </ Picture>
<Picture> 2d / 2d2190400fca11e71a9a141877341409 </ Picture>
<Article> 7696 </ Article>
<Picture> 67 / 670cfeec16b111e6cd8f141877341409 </ Picture>
send answer on email please vitaly9oleg@gmai.com


can you modify this program or recommend yours?


How to modify this program that it renames jpg files from file Namefile.txt
@Echo Off
Set "InFile=C:\t\*.jpg"
Set "ArtFile=C:\t\namefile.txt"

Set /A N0=100001
Set /A N=%N0%-1

FOR /F "usebackq tokens=1,2,4 delims=^<>/ " %%i IN ("%ArtFile%") DO (
If "%%k"=="" (Set /A N+=1 &Call Set "@@Art%%N%%=%%j")
If Not "%%k"=="" Call Set "@@Fnm%%N%%=%%k"
)
FOR %%f IN ("%InFile%") DO (
FOR /L %%i IN (%N0%,1,%N%) DO Call :ArtRen "%%f" "%%@@Fnm%%i%%" "%%@@Art%%i%%"
)
Exit /B

:ArtRen
If /I "%~n1"==%2 Ren %1 "%~3%~x1"
Exit /B\

Post Reply