Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch File Help  (Read 2816 times)

0 Members and 1 Guest are viewing this topic.

turtlemp346

    Topic Starter


    Newbie

    • Experience: Beginner
    • OS: Windows 7
    Batch File Help
    « on: June 04, 2018, 07:30:15 AM »
    I am a beginner on bat files and managed to piece together the following bat file. It goes to a folder and extracts all tiffs to a single image, converts them to a png and renames them by adding "_page_0001"which looks like "MP0000624_001__page_0001.png". The second command removes the "page_00" so it like "MP0000624_001_01.png" when completed. The "MP0000624_001.tif" is the original name of the tiff. I then found out that it needs to make a copy of the first image and rename it to be "_02" and if there are any other images within that tiff it will name them start with "_03" and so fourth. Any help is much appreciated.

    for %%a in ("%CD%\TIFF\*.tif") do (
      "C:\Program Files (x86)\IrfanView\i_view32.exe" "%%~fa"/killmesoftly /extract=("%CD%\PNG",png)

    setlocal enabledelayedexpansion
    set deletestring=page_00

    cd "%CD%\PNG"

    for /f "delims==" %%F in ('dir /b *.png   ^| find "%deletestring%"') do (
       set oldfilename=%%F
       set newfilename=!oldfilename:%deletestring%=!
        Ren "!oldfilename!" "!newfilename!"
       )