Announcement

Collapse
No announcement yet.

Command Line: /extract -- change in behaviour?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Command Line: /extract -- change in behaviour?

    Hi,

    I am using irfanview in command line to extract all pages from a multipage file.
    e.g.
    Code:
    iview_32 test.tif /tifc=4 /extract=(.\converted\,tif) /cmdexit
    up to version 4.35 the index for the extracted files began with 0
    output:
    Code:
    test_page_0000.tif
    test_page_0001.tif
    test_page_0002.tif
    but with higher version it begins with 1
    output:
    Code:
    test_page_0001.tif
    test_page_0002.tif
    test_page_0003.tif
    I didn't found any option to set the index to 0 again.
    Because my processes depends on the 0 index I can't update to newer versions.
    I could not find anything about it in the changelog.

    Is this a bug or is it a behaviour change?
    Or is there somewhere an option to set it back to 0?

    joerch

    #2
    It's not a bug, it's a change, and a sensible one if you ask me. Zero-based indexing is 'unnatural' outside of programming context. I don't see a way to revert IV to old behaviour but as a workaround you can use this batch script to convert filenames to zero-based index.
    Code:
    @Echo off & SetLocal
    
    Set Basename=test_page_
    Set Ext=tif
    
    For /F %%G in ('2^>NUL Dir /B "%~dp0\%Basename%????.%Ext%"^|Find /V /C ""') Do (Set K=%%G)
    If %K%==0 Goto Exit
    
    Set G=0
    Set H=1
    
    :RenLoop
    
    If %G% LSS 10 (Set I=000) Else (
       If %G% LSS 100 (Set I=00) Else (
          If %G% LSS 1000 (Set I=0) Else (
             Set I=)))
    If %H% LSS 10 (Set J=000) Else (
       If %H% LSS 100 (Set J=00) Else (
          If %H% LSS 1000 (Set J=0) Else (
             Set J=)))
    
    Ren "%~dp0\%Basename%%J%%H%.%Ext%" "%Basename%%I%%G%.%Ext%"
    
    Set /A G+=1
    Set /A H+=1
    If not %G%==%K% Goto RenLoop
    
    :Exit

    Comment

    Working...
    X