How to copy files using command prompt script?

chokka used Ask the Experts™
I have a folder of around 1000 .tif files.

Out of these, I need to copy or move 100 selected tif files to a new folder.

Those 100 files are there in the text file which is located in the same folder along with 1000 tif files.

So using this text file as input parameter , I need to copy the tif in that folder & move it to a new folder.

How to write a batch script to do so? Please :)
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
"Batchelor", Developer and EE Topic Advisor
Top Expert 2015
@echo off
set target=..\targetfolder
set file2move=files2move.txt
pushd ~dp0
for /F "delims=" %%F in (%files2move%) do move "%%~F"  %target%

Open in new window

This .cmd file will move the files from the folder the script is stored in. The file containing which TIF files to move, and the location to move them to, are stated in the first two variables.
Would that work for you?
yo_beeDirector of Information Technology

I like robocopy for this.

Here is the switches I would use

Robocopy "source folder path" "destination path" *.txt /e /mov /w:0 /r:0
I don't think RoboCopy is a native DOS command and as far as I am aware it is not a known command in Windows 10.

Qlemo's batch file code seems to do the job however, please permit me to offer the following approach:


IF NOT EXIST "newfolder" MD "newfolder"
FOR /F "DELIMS=" %%a IN (filenames.txt) DO MOVE "%%a"  "newfolder"

Open in new window

C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Bill PrewTest your restores, not your backups...
Top Expert 2016

Hi Paul,

ROBOCOPY has been bundled with Windows since the Vista version I believe.  Certainly is native in recent versions of Windows including version 10.

Qlemo"Batchelor", Developer and EE Topic Advisor
Top Expert 2015

The issue here with RoboCopy is that only certain files listed in a text file should be moved. You can't do that in a single sweep with RoboCopy, and so it is loosing its advantages.
yo_beeDirector of Information Technology

That is far.
Ha ha ha ha... What a fool I am. I was forced to enter HELP in a Windows 10 console, something I haven't done in years, only to be greeted by a list of DOS commands including ROBOCOPY so please ignore my previous comment regarding the ROBOCOPY command.

Thank you Bill Prew.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial