Page 1 of 1

Move command question

Posted: 07 Jul 2011 12:27
by ED209
Hi all,

I'm wondering is it possible to do a dos move using an input file.. I've 400+ files to move from one dir to another and thought it might be a bit cleaner if I could use a txt file as the input but not sure if thats possible..

Any help would be appreciated..

Thanks...

Re: Move command question

Posted: 07 Jul 2011 12:32
by aGerman
How does your list look like? Only the source file names line by line?

Regards
aGerman

Re: Move command question

Posted: 07 Jul 2011 12:44
by ED209
Hi,

At the minute it's just in a txt file in the following format:

About.bmp
ACTDATA.CSV
APPTRACK.EXE
ARA_FIHI.CSV


and so on...

Re: Move command question

Posted: 07 Jul 2011 12:54
by aGerman
Untested:

Code: Select all

@echo off &setlocal
set "sourceFolder=c:\path\to\your\files"
set "destinationFolder=c:\path\to\move\the\files"
set "listFile=myFileList.txt"

for /f "usebackq delims=" %%a in ("%listFile%") do (
  move "%sourceFolder%\%%~a" "%destinationFolder%\"
)

Regards
aGerman

Re: Move command question

Posted: 07 Jul 2011 13:12
by ED209
Just did a quick test and it works great..

Thanks a mil for your help..

EDIT**
Actually, would you mind explaining what the below is doing?

Code: Select all

usebackq delims=" %%a in

Re: Move command question

Posted: 07 Jul 2011 13:54
by aGerman
Of ourse.
The FOR /F loop iterates the list file line by line.
I used USEBACKQ for being able to enclose the file name in double quotes (that was done because I didn't know whether the file name of your list contains spaces).
Normally the line read from the list would be delimited in tokens by spaces and tabs. For that reason I used DELIMS= to disable the default delimiters and make sure you get the entire line into variable %%a.

Have a look at the command index to learn more.

Regards
aGerman

Re: Move command question

Posted: 07 Jul 2011 13:57
by ED209
Cool, thanks again.. I'll have a read up on the command index now..

Re: Move command question

Posted: 07 Jul 2011 16:17
by Ed Diarrhea
ED209 wrote:!?!command index!?!