1

I have two text files - sample1.txt and sample2.txt which contains path of moving the files from sample1 to sample2. To make it more clear. I have these two files:
Sample1.txt

C:\Users\borkarv\Desktop\Sample\ABC\New Text Document.txt C:\Users\borkarv\Desktop\Sample\ABC\sdfsdf .txt
C:\Users\borkarv\Desktop\Sample\XYZ\New Text Document.txt C:\Users\borkarv\Desktop\Sample\OPQ\asdasd.txt
C:\Users\borkarv\Desktop\Sample\OPQ\New Text Document.txt

Sample2.txt

C:\Users\borkarv\Desktop\Sample\ABC\Backup\New Text Document.txt C:\Users\borkarv\Desktop\Sample\ABC\Backup\sdfsdf .txt C:\Users\borkarv\Desktop\Sample\XYZ\Backup\New Text Document.txt C:\Users\borkarv\Desktop\Sample\OPQ\Backup\asdasd.txt C:\Users\borkarv\Desktop\Sample\OPQ\Backup\New Text Document.txt

I want to move all the files from sample1.txt to sample2.txt such that path1 from sample1.txt goes in path1 of sample2.txt and so on.

I tried to use two for loops for this but that creates a problem as the files get overwritted.

FOR /F "delims=/" %%x in (sample1.txt) DO ^
FOR /F "delims=/" %%y in (sample2.txt) DO ^
move "%%x" "%%y" 

I was thinking of putting && in between the 2 for loops but that doesnt work.

Vaibhav Borkar
  • 171
  • 2
  • 12
  • Please provide examples of what filemoves would take place given your sample data – Magoo Oct 09 '17 at 16:46
  • That be all text files that are going to get moved. The text files might contain a lot of data though(the data is not arranged in a specific order) – Vaibhav Borkar Oct 09 '17 at 16:49
  • 1
    So the question you should ask is: [How can two text files be read in parallel by a batch file?](https://stackoverflow.com/q/38214874) – aschipfl Oct 09 '17 at 17:03
  • Thats right! The site was useful though I am still confused how they were used. I saw the comments and all but didnt understand. How can I move them? – Vaibhav Borkar Oct 09 '17 at 17:58
  • You are making this harder than it has too be. You don't need the second file. If the only change is moving it to a sub folder named backup, then all you need is the first file. – Squashman Oct 09 '17 at 18:01
  • How do I do that then? – Vaibhav Borkar Oct 09 '17 at 18:02
  • 1
    Looking back at all the other questions you have asked about this same project you are working on, what you are doing makes absolutely no sense to me. It literally baffles me. – Squashman Oct 09 '17 at 18:04
  • @Squashman that is 1 component.Cannot explain the whole thing. Thanks for your help so far though – Vaibhav Borkar Oct 09 '17 at 18:11

0 Answers0