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!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

DOS read file and rename

MonicaOM12MonicaOM12 Posts: 2Member
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


Sign In or Register to comment.