Avatar of chokka
chokka
Flag 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 :)
Windows Batch

Avatar of undefined
Last Comment
Paul Tomasi

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Qlemo

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
yo_bee

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 Tomasi

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:

@ECHO OFF

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

Open in new window

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.


»bp
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Qlemo

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_bee

That is far.
Paul Tomasi

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.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.