title: Windows Batch file - strip leading characters
body: <p>I have a batch file which copies some local files up to a google storage area using the gsutil tool. The gsutil tool produces a nice log file showing the details of the files that were uploaded and if it was OK or not. </p>
  
  <pre><code>Source,Destination,Start,End,Md5,UploadId,Source Size,Bytes Transferred,Result,Description
  file://C:\TEMP\file_1.xlsx,gs://app1/backups/file_1.xlsx,2018-12-04T15:25:48.428000Z,2018-12-04T15:25:48.804000Z,CPHHZfdlt6AePAPz6JO2KQ==,,18753,18753,OK,
  file://C:\TEMP\file_2.xlsx,gs://app1/backups/file_2.xlsx,2018-12-04T15:25:48.428000Z,2018-12-04T15:25:48.813000Z,aTKCOQSPVwDycM9+NGO28Q==,,18753,18753,OK,
  </code></pre>
  
  <p>What I would like to do is to </p>
  
  <ul>
  <li>check the status result in column 8 (OK or FAIL)</li>
  <li>If the status is OK then move the source file to another folder (so that it is not uploaded again).</li>
  </ul>
  
  <p>The problem is that the source filename is appended with "file://" which I can't seem to remove, example</p>
  
  <pre><code>file://C:\TEMP\file_1.xlsx
  </code></pre>
  
  <p>needs to be changed into this</p>
  
  <pre><code>C:\TEMP\file_1.xlsx
  </code></pre>
  
  <p>I am using a for /f loop and I am not sure if the manipulation of the variables %%A is different within a for /f loop.</p>
  
  <pre><code>@echo off
  
  rem copy the gsutil log file into a temp file and remove the header row using the 'more' command.
  more +1 raw_results.log &gt; .\upload_results.log
  
  rem get the source file name (column 1) and the upload result (OK) from column 8
  for /f "tokens=1,8 delims=," %%A in (.\upload_results.log) do (
          echo The source file is %%A , the upload status was %%B 
  
          set line=%%A
          set line=!line:file://:=! &gt;&gt; output2.txt echo !line!
          echo !line!
  
  )
  </code></pre>
  
  <p>The output is like this.</p>
  
  <pre><code>The source file is file://C:\TEMP\file_1.xlsx , the upload status was OK
  The source file is file://C:\TEMP\file_2.xlsx , the upload status was OK
  </code></pre>
  
  <p>I'm expecting it to dump the altered values out into a new file but it is not producing anything at the moment.
  Normally I would extract from a specific character to the end of the string with something like this but it doesn't work with my For/f loop. </p>
  
  <pre><code>%var:~7%
  </code></pre>
  
  <p>Any pointers or a different way of doing it greatly appreciated.</p>