How to copy files using command prompt script?

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 :)
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
@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?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
yo_beeDirector of Information TechnologyCommented:
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
Paul TomasiCommented:
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

Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Bill PrewIT / Software Engineering ConsultantCommented:
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 AdvisorCommented:
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 TechnologyCommented:
That is far.
Paul TomasiCommented:
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.