Advertisement
WadeRollins2710

Create test directory

Mar 17th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.18 KB | None | 0 0
  1. import os
  2.  
  3. def getListOfFiles(dirName):
  4.     # create a list of file and sub directories
  5.     # names in the given directory
  6.     listOfFile = os.listdir(dirName)
  7.     allFiles = list()
  8.     # Iterate over all the entries
  9.     for entry in listOfFile:
  10.         # Create full path
  11.         fullPath = os.path.join(dirName, entry)
  12.         # If entry is a directory then get the list of files in this directory
  13.         if os.path.isdir(fullPath):
  14.             allFiles = allFiles + getListOfFiles(fullPath)
  15.         else:
  16.             allFiles.append(fullPath)
  17.                
  18.     return allFiles
  19.  
  20. with open("filename.txt", "r") as f:
  21.     files = [line.strip() for line in f.readlines()]
  22.     for item in files:
  23.         os.system("mkdir ntttest\\" + item)
  24.         for i in range(1, 11):
  25.             if (i != 10):
  26.                 test_folder = "Test0" + str(i)
  27.             else:
  28.                 test_folder = "Test10"
  29.             os.system("mkdir ntttest\\" + item + "\\" + test_folder)
  30.             os.system("copy nul .\\ntttest\\" + item + "\\" + test_folder + "\\" + item + ".INP")
  31.             os.system("copy nul .\\ntttest\\" + item + "\\" + test_folder + "\\" + item + ".OUT")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement