Note that there are some explanatory texts on larger screens.

plurals
  1. POpath is expanding to individual elements?
    text
    copied!<p>I am attempting to create a batch file to backup the directories in my \iTunes\Movies\ folder to an external drive if they do not already exist on the external drive:</p> <pre><code>@echo off cls SetLocal EnableDelayedExpansion for /f "delims=" %%F in ('dir /ad /b') do ( if not exist g:\movies\%%F ( echo Copying %%F to G:\Movies\%%F rem md G:\Movies\%%F rem copy M:\iTunes\Movies\%%F\*.* G:\Movies\%%F ) ) </code></pre> <p>and here is the output:</p> <pre><code>Code: Copying The Princess Bride to G:\Movies\The Princess Bride Copying Green to G:\Movies\Green Copying Red to G:\Movies\Red Copying Princess to G:\Movies\Princess Copying Bride to G:\Movies\Bride Copying The Green Mile to G:\Movies\The Green Mile Copying The Shawshank Redemption to G:\Movies\The Shawshank Redemption Copying Grape to G:\Movies\Grape Copying Roof to G:\Movies\Roof Copying On to G:\Movies\On Copying Fiddler On the Roof to G:\Movies\Fiddler On the Roof Copying Brief to G:\Movies\Brief Copying Number to G:\Movies\Number Copying to to G:\Movies\to Copying the to G:\Movies\the Copying Gilbert Grape to G:\Movies\Gilbert Grape Copying Torino to G:\Movies\Torino Copying Sherlock Holmes to G:\Movies\Sherlock Holmes Copying Gran Torino to G:\Movies\Gran Torino Copying I Am Number Four to G:\Movies\I Am Number Four Copying Too Big to Fail to G:\Movies\Too Big to Fail Copying Pelican to G:\Movies\Pelican Copying The Shunning to G:\Movies\The Shunning Copying Inside Job to G:\Movies\Inside Job Copying Shawshank to G:\Movies\Shawshank Copying Holmes to G:\Movies\Holmes Copying Four to G:\Movies\Four Copying Am to G:\Movies\Am Copying Big to G:\Movies\Big Copying Job to G:\Movies\Job Copying Mile to G:\Movies\Mile Copying Fail to G:\Movies\Fail Copying The Pelican Brief to G:\Movies\The Pelican Brief Copying Shunning to G:\Movies\Shunning Copying Redemption to G:\Movies\Redemption Copying Labyrinth to G:\Movies\Labyrinth Copying The Hunger Games to G:\Movies\The Hunger Games M:\iTunes\Movies&gt; </code></pre> <p>it is not only correctly using the full directory name of say, "The Green Mile", but also incorrectly using "The" and "Green" and "Mile" for each directory that exists in the iTunes\Movies folder but does not exist in the External drive.</p> <p>I have tried it with and without EnableDelayedExpansion and tried various types of variable assignments to no avail.</p> <p>I just don't get it, I have "delims=" programmed and I have tried it with double quotes around the %%F so why is it breaking up the expression in to individual elements?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload