DOS read file and rename

Here is what I want to do:
I have HTML files named as follows:
diagram113660819130 - PREPAY AUDIT-content.html
diagram126591269210 - CAS MAIN-content.html

Image files named as follows:


I want to rename the .pdf using the HTML file names
REN diagram1136608191.pdf 30 - PREPAY AUDIT.pdf
REN diagram1265912692.pdf 10 - CAS MAIN.pdf

The pdf name may be 16 or 17 characters long.

I am stuck with the following code

@echo off
del digfiles.txt
dir diagram*-content.html /B /O :N >digfiles.txt
FOR /F "tokens=1, 2, 3*" %%i in (digfiles.txt) do (
echo %%i %%j %%k %%l
dir ..images%%i:0,16%*.pdf

I cannot get it to echo the first 16 characters
neither can I get the directory listing of the giveb pdf.
I am far from doing the rename if I cannot even seperate the first 16 characters...please help.

Thank You


  • @echo off
    if exist digfiles.txt del digfiles.txt
    dir diagram*.html /B /O :N >digfiles.txt
    for /f "tokens=1,2,3,4,5 delims=-" %%i in (digfiles.txt) do echo %%j %%m

    I not understand all of your question!!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion