title: How to include search directory into FOR-DO loop while using "delims=" for a list of extensions
body: <p>In Windows 10, via batch, I want to include the directory which a list of file extensions are to be searched; and process those files with those specific extensions in that folder.</p>
  <p>I have a batch file and I drag&amp;drop a folder onto it (or its shorcut) to invoke the batch.
  Thus the folder path is passed to the batch file as %1 argument/parameter.
  My need is NOT related with passing files or etc.; more than one folders; whether or not there are subdirs in that folder... as parameter(s).</p>
  <p>The portion of the batch which I need help is as follows:</p>
  <pre><code>PUSHD %1
  REM or by CD %1
  FOR /F &quot;delims=&quot; %%I in ('dir /A-D /B *.tif *.jpg 2^&gt;NUL') DO (
  REM or by, though unwanted: FOR /F &quot;delims=&quot; %%I in ('dir /A-D /B %1\*.tif %1\*.jpg 2^&gt;NUL') DO (
  REM  CALL :DOSOMETHING &quot;with %~dpnx1\%%I and other arguments&quot;
  )
  </code></pre>
  <p>As it is seen in the code, I'm able to <em>Do Something on/process</em> files successfully with TIF and JPG extensions in folder %1 by either using <code>PUSHD</code> that directory or <code>CD</code> to that directory. Or by omitting PUSHD and CD; and adding/changing <code>%1\*.TIF</code> etc. in front of delimeters in the list. All are ok. But I would like to use an elegant approach to perform this. But not via a list of <code>%1\*.EXTENSION</code> from a lookup file. <strong>Rather, including %1 into FOR line somewhere between <code>FOR</code> and <code>(</code> (opening paranthesis).</strong> Is it possible? If so, how please? I did read some RTFM but fail to comprehend if there are any help for this. I also made some combinations of try&amp;error but to no avail.</p>
  <p>You may well say there is no need to use <code>&quot;%~dpnx1\%%I&quot;</code> and using only <code>&quot;%%I&quot;</code>, since PUSHD/CD is used, will do the same thing all along in the batch file, but I want to get rid of PUSHD/CD if possible.</p>
  <p>Another point, if it is appropriate to ask a non-relevant question...
  Although I did not use <code>usebackq</code> option inside <code>&quot;delims=&quot;</code>, and/or I did not use %1 in surrounding double quotes (<code>%1</code> only, not as <code>&quot;%1&quot;</code>), the code is able to be executed successfully for both directories &amp; file names with spaces. May I ask why?</p>