def copySDFiles(sdFilesToCopy, targetFolder, agsServices, portalProps):
    
    print '\n' + sectionBreak
    print 'Copy SD Files...'
    print sectionBreak
    print '{:<60s}{} {:<100s}'.format('Service Folder//Name.Type', '|', 'SD File Path: From/To')
    print sectionBreak1
    for service, serviceInfo in sdFilesToCopy.iteritems():
        sdFilePath = serviceInfo['path']
        sdFile = os.path.basename(sdFilePath)
        sdParentFolder = os.path.basename(os.path.dirname(sdFilePath))
        outputFolder = os.path.join(targetFolder, sdParentFolder)
        outputFilePath = os.path.join(outputFolder, sdFile)
        print '{:<60s}{}{:<100s}'.format(service, '|', ' From: ' + sdFilePath)
        print '{:>61s}{:<100s}'.format('|', ' To: ' + outputFilePath)
        
        # Create target folder if it does not exist and copy file
        if not os.path.exists(outputFolder):
            os.makedirs(outputFolder)
        copy2(sdFilePath, outputFilePath)
        
        os.chdir(outputFolder)
        
        serviceInfo = agsServices[service]
        json.dump(serviceInfo, open(os.path.splitext(sdFile)[0] + '_s_info.json','w'))
        
        props = portalProps[service]
        json.dump(props, open(os.path.splitext(sdFile)[0] + '_p_info.json','w'))
        
    print sectionBreak
Copy SD files to target folder.
dataset/ETHPy150Open Esri/ops-server-config/SupportFiles/GetSDFiles.py/copySDFiles