DOS read file and rename - Programmers Heaven

Howdy, Stranger!

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

Categories

DOS read file and rename

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

Image files named as follows:

/images
diagram1136608191.pdf
diagram1265912692.pdf

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
[b]echo.%i:~0,16%[/b]
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


Comments

  • stevewustevewu Posts: 1Member
    @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
    pause


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