Batch to move files baed on a list with source and destination paths

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Oms
Posts: 4
Joined: 11 Jul 2016 12:26

Batch to move files baed on a list with source and destination paths

#1 Post by Oms » 11 Jul 2016 13:11

Hi all,
I am new to this Forum and Dos Batch processing.
I have to move a large ammount of images. I have a text file where the images are listed individually with their source path and their destination path. Something like this:

Input Output
C:\projectA\asia\image1 Y:\blue\image1
C:\africa\image2 Y:\account\image2


Is there any batch that allows me to move the images based on my text file.

Thanks a lot

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Batch to move files baed on a list with source and destination paths

#2 Post by ShadowThief » 12 Jul 2016 01:09

Is the line Input Output part of the file? Will the paths contain any spaces?

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

Re: Batch to move files baed on a list with source and destination paths

#3 Post by Compo » 12 Jul 2016 02:28

My guess is
  • multiple space or tab delimited file without doublequotes but with potential spaces in either 'column'
  • homework type project

Oms
Posts: 4
Joined: 11 Jul 2016 12:26

Re: Batch to move files baed on a list with source and destination paths

#4 Post by Oms » 12 Jul 2016 03:15

ShadowThief wrote:Is the line Input Output part of the file? Will the paths contain any spaces?


Hi, the Input Output does not need to be in the file. The Paths do not have any spaces. Cheers.

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

Re: Batch to move files baed on a list with source and destination paths

#5 Post by Compo » 12 Jul 2016 03:44

I'll try that again…
  • Is the file in columns separated by multiple spaces?
  • Is the file in columns separated by horizontal tabs?
  • Is the file in columns separated by a single space?

When you say the Input Output does not have to be in the file, are you creating the file in such a way as you have control over its content?

If the file is as we see it on the forum board, and you're not including the column headers, all you need to do is run each line of the file with the word move in front of it.

Oms
Posts: 4
Joined: 11 Jul 2016 12:26

Re: Batch to move files baed on a list with source and destination paths

#6 Post by Oms » 12 Jul 2016 03:49

Compo wrote:I'll try that again…
  • Is the file in columns separated by multiple spaces?
  • Is the file in columns separated by horizontal tabs?
  • Is the file in columns separated by a single space?

When you say the Input Output does not have to be in the file, are you creating the file in such a way as you have control over its content?


The file is a text file, it has currently headers and columns are semapared by a single space, but I can modify it needed.

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

Re: Batch to move files baed on a list with source and destination paths

#7 Post by Compo » 12 Jul 2016 04:02

From the command line.
With your header:

Code: Select all

For /F "UseBackQ Skip=1 Delims=" %A In ("C:\Users\Oms\Test.txt") Do @Move %A
Without your header:

Code: Select all

For /F "UseBackQ Delims=" %A In ("C:\Users\Oms\Test.txt") Do @Move %A

From a batch file.
With your header:

Code: Select all

For /F "UseBackQ Skip=1 Delims=" %%A In ("C:\Users\Oms\Test.txt") Do Move %%A
Without your header:

Code: Select all

For /F "UseBackQ Delims=" %%A In ("C:\Users\Oms\Test.txt") Do Move %%A

Change the path inside the parentheses to suit your requirements and try it on test contents first!

Oms
Posts: 4
Joined: 11 Jul 2016 12:26

Re: Batch to move files baed on a list with source and destination paths

#8 Post by Oms » 12 Jul 2016 04:10

Compo wrote:From the command line.
With your header:

Code: Select all

For /F "UseBackQ Skip=1 Delims=" %A In ("C:\Users\Oms\Test.txt") Do @Move %A
Without your header:

Code: Select all

For /F "UseBackQ Delims=" %A In ("C:\Users\Oms\Test.txt") Do @Move %A

From a batch file.
With your header:

Code: Select all

For /F "UseBackQ Skip=1 Delims=" %%A In ("C:\Users\Oms\Test.txt") Do Move %%A
Without your header:

Code: Select all

For /F "UseBackQ Delims=" %%A In ("C:\Users\Oms\Test.txt") Do Move %%A

Change the path inside the parentheses to suit your requirements and try it on test contents first!



Thanks a lot! It work perfectly :)

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Batch to move files baed on a list with source and destination paths

#9 Post by foxidrive » 13 Jul 2016 19:39

Oms wrote:The file is a text file, it has currently headers and columns are separated by a single space, but I can modify it needed.


Oms, I'm only commenting here that a script or program is pretty dumb and has exact commands to perform a task. If the programmer can't see what is inside the file then the script will usually fail when unexpected text is seen by the commands.

Shorter reply: make sure you give a full picture of the information when you ask questions for your future tasks.

Post Reply