title: Transpose Tiff files from folder based on parameter (Hyphen) to CSV
body: <p>I have the folder which contains <code>tiff</code> files, in between few images are marked with "-", which indicates transpose parameter.Once it encounter"-" the files reflecting below them are transposed until another "-" is triggered.</p>
  
  <pre><code>001-001.tif
  </code></pre>
  
  <hr>
  
  <pre><code>@echo off
  setlocal enableDelayedExpansion
  
  set root=D:\Testing\100
  set csv=E:\JOE\Transpose1.csv
  
  set line=-
  set curpath=
  set new=
  &gt;nul copy nul: %csv%
  
  for /f %%F in ('dir /s/b %root%\*.tif') do (
    if not "!curpath!" == "%%~dpF" set new=y
    set fname=%%~nxF
    if not "!fname:-=!" == "!fname!" set new=y
  
    if defined new (
      if defined line echo !line!&gt;&gt; %csv%
      set line=%%~dpF
      set new=
    )
  
    set line=!line!,%%~nxF
    set curpath=%%~dpF
  )
  if defined line echo !line!&gt;&gt; %csv%
  </code></pre>
  
  <hr>
  
  <pre><code>002.tif
  003.tif
  004-004.tif
  </code></pre>
  
  <p>I have the code which was good enough to go but recently noticed with error output.</p>
  
  <p><a href="https://i.stack.imgur.com/wqflO.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wqflO.jpg" alt="code"></a></p>
  
  <p><a href="https://i.stack.imgur.com/7tDEV.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7tDEV.jpg" alt="Transpose output"></a></p>