• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 93
  • Last Modified:

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 :)
0
chokka
Asked:
chokka
  • 2
  • 2
  • 2
  • +1
1 Solution
 
QlemoBatchelor, 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%
popd

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?
0
 
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
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:

@ECHO OFF

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

Open in new window

0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
Bill PrewCommented:
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
2
 
QlemoBatchelor, 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.
1
 
yo_beeDirector of Information TechnologyCommented:
That is far.
0
 
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.
2
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now