Link to home
Start Free TrialLog in
Avatar of chokka
chokkaFlag for United States of America

asked on

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 :)
Avatar of Qlemo
Flag of Germany image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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

Avatar of Bill Prew
Bill Prew

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.

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.
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.