For example: Question, moving a folder (T061RR7N1) containing a Specific file (ReadCMI), to folder: C:\\...\DUT0
Kevin M. Wilson
kevinmwilson1956 at yahoo.com
Wed Jan 27 16:19:44 EST 2021
for path, dir, files in os.walk(myDestinationFolder):
# for path, dir, files in os.walk(destfolder):
print('The path is %s: ', path)
print(files)
os.chdir(mySourceFolder)
if not os.path.isfile(myDestinationFolder + file):
# if not os.path.isfile(destfolder + file):
print('The file is %s: ', file)
shutil.copytree(mySourceFolder, myDestinationFolder)
# os.rename(path + '\\' + file, myDestinationFolder + file)
# os.rename(path + '\\' + file, destfolder + file)
os.rename(path + '\\' + file, myDestinationFolder + file)
elif os.path.isfile(myDestinationFolder + file):
# os.rename(path + '\\' + file, destfolder + file)
shutil.copytree(mySourceFolder, myDestinationFolder)
So I would very much appreciate your ideas on the above statements!Because...I think I've got the wrong function (os.path.isfile), when I should be (s/b) using a stepped approach!Note: program allows input of ID = T061RR7N1 (for example)1) find the folder containing "file": where folder = T061RR7N1, and file is "ReadCMI"; if TRUE, shutil.copytree C:\\...\T061RR7N1\ReadCMI (TO) C:\\...\DUT[?], where [?] is a num from 0 - 15.2) append to C:\\...\DUT[?]\T061RR7N1, which contains "ReadCMI"!
and would you mind telling me why this works (in every example I've found on the internet): r'C:\\anyfolder\\anyotherfolder\\'...what does the "r" signify? If it's 'read', why can't I use the 'a' for append?
KMW
"The only way to have experience is by having the experience"!
More information about the Python-list
mailing list