AnsweredAssumed Answered

Nested loop problem

Question asked by JB1234510 on Jan 16, 2015
Latest reply on Jan 16, 2015 by JB1234510

I do know it's not the python forum here around, but maybe someone knows that.

 

Need a migration script to copy folders. That's what I have so far:

 

import shutil, os, sys
# import numpy as np

QFile = r"R:\natura 2000\SG-Besprechungen\Migration2015_Q.txt"
ZFile = r"R:\natura 2000\SG-Besprechungen\Migration2015_Z.txt"

f = open(QFile, 'r')
for line in f:
    print(line)
    # print f.readline
    f1 = open(ZFile, 'r')
    for line1 in f1:
        print(line1)

    ##    src = line
    ##    dest = r"R:\SG-C\SIC_20150115"

        if sys.platform == 'win32':
            os.system('xcopy "%s" "%s"' % (line, line1) + " /Y /M /S /E /D")
            print 'xcopy "%s" "%s"' % (line, line1) + " /Y /M /S /E /D "
        else:
            shutil.copy(line, line1)

 

Result is that:

 

R:\natura 2000\8847.00 Richtlinien\Bauleitplanung

 

R:\SG-C\8850.20-1 Allgemeine Unterlagen Natura 2000

 

xcopy "R:\natura 2000\8847.00 Richtlinien\Bauleitplanung

" "R:\SG-C\8850.20-1 Allgemeine Unterlagen Natura 2000

" /Y /M /S /E /D

R:\SG-C\8850.20-2 Unterlagen aus anderen Bundesländern (Why that?)

 

xcopy "R:\natura 2000\8847.00 Richtlinien\Bauleitplanung

" "R:\SG-C\8850.20-2 Unterlagen aus anderen Bundesländern

" /Y /M /S /E /D

R:\natura 2000\8847.02 allgemein

 

R:\SG-C\8850.20-1 Allgemeine Unterlagen Natura 2000 (Double?)

 

xcopy "R:\natura 2000\8847.02 allgemein

" "R:\SG-C\8850.20-1 Allgemeine Unterlagen Natura 2000

" /Y /M /S /E /D

R:\SG-C\8850.20-2 Unterlagen aus anderen Bundesländern

 

xcopy "R:\natura 2000\8847.02 allgemein

" "R:\SG-C\8850.20-2 Unterlagen aus anderen Bundesländern

" /Y /M /S /E /D

Outcomes