title: batch copy unique files to new folder
body: <p>The linked question may assist in context of my query: <a href="https://stackoverflow.com/questions/1100452/get-filename-in-batch-for-loop/42989726#42989726">Get filename in batch for loop</a></p>
  
  <p>I'm just not catching on to the rules of substitution, but I think this is a question with a similar answer...</p>
  
  <p>I'm attempting the same sort of move action using the following batch sequence.  Anyone able to help me correct the syntax?</p>
  
  <pre><code>@echo off
  
  set source=C:\Users\my name\some long path with spaces
  set target=C:\Users\my name\a different long path with spaces
  
  for %%F in ("%source%") do if not exist "%target%\%~nF.jpg" copy "%%F" "%target%\%~nF.jpg"
  </code></pre>
  
  <p>The idea is to copy all files with no extension where destination with matching filename exists with specific extension into the destination with correct extension.  Thanks in advance is anyone is able to assist!</p>
  
  <hr>
  
  <p>Edit:
  Thanks for the references Daniel, but I'm not trying to copy a filename to destination with matching extension.  I'm trying to copy filename to same filename with new extension</p>
  
  <p>Example:</p>
  
  <pre><code>source\filename001
  destination\filename001.jpg
   - do nothing
  source\filename002
  destination\{no match}
   - copy source\filename002 to destination\filename002.jpg
  </code></pre>
  
  <p>Alex, I'm not sure what to do from there.  I looked at the output when running without echo off, and that's why I'm posting this question.  I don't understand how to modify the substitutions to work correctly.</p>
  
  <hr>
  
  <p>Output errors from batch:</p>
  
  <pre><code>for %%~F in ("%source%") do if not exist "%target%\%~nF.jpg" copy "%%F" "%target%\%~nF.jpg"
  </code></pre>
  
  <blockquote>
    <p>The following usage of the path operator in batch-parameter
        substitution is invalid: %~nF.jpg" copy "%%F" "%target%\%~nF.jpg"</p>
  </blockquote>
  
  <hr>
  
  <pre><code>for %%F in ("%source%") do if not exist "%target%\%~nF.jpg" copy "%%~F" "%target%\%~nF.jpg"
  </code></pre>
  
  <blockquote>
    <p>The following usage of the path operator in batch-parameter
        substitution is invalid: %~nF.jpg" copy "%%~F" "%target%\%~nF.jpg"</p>
  </blockquote>
  
  <hr>
  
  <p>SOLUTION: Thanks for the assist/solution/guidance!</p>
  
  <pre><code>set "source=C:\Users\my name\some long path with spaces"
  set "target=C:\Users\my name\a different long path with spaces"
  
  for /F "delims=" %%F in (
    'Dir /B "%source%\*." '
  ) do if not exist "%target%\%%~nF.jpg" copy "%source%\%%~F" "%target%\%%~nF.jpg"
  </code></pre>