Copying Folders and Files From A List in Command Prompt

Posted: July 29, 2015 in Uncategorized

I had a unique request to copy a list of folders out of a greater collection of folders. Seeking the best way to do this I found this solution thanks to sidesofmarch:

Step 1:

Create a text (ex: migrate.txt) file containing a list of folders to be copied or moved, each folder name on a new line.

Step 2:

Run a for/in loop while inside the Windows Command Prompt. Add the /move attribute to robocopy to move instead of copy. Google “robocopy” for more options. In this example %i is the folder name which copies it to the root of E: drive.

for /f "delims=" %i in (migrate.txt) do robocopy "%i" "E:\%i" /e /z /MT /log+:log.txt

Note: if you put this command in a batch file use %%i instead of %i

Tested 7/29/2015 on Windows 10

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s