72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
else:
raise
def moveFolderContent (spSrc, spDst, sPrefix="", bLog=False):
"move folder content from <spSrc> to <spDst>: if files already exist in <spDst>, they are replaced. (not recursive)"
try:
for sf in os.listdir(spSrc):
spfSrc = os.path.join(spSrc, sf)
if os.path.isfile(spfSrc):
spfDst = os.path.join(spDst, sPrefix + sf)
shutil.move(spfSrc, spfDst)
if bLog:
print("file <" + spfSrc + "> moved to <"+spfDst+">")
|
>
>
>
>
>
>
|
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
else:
raise
def moveFolderContent (spSrc, spDst, sPrefix="", bLog=False):
"move folder content from <spSrc> to <spDst>: if files already exist in <spDst>, they are replaced. (not recursive)"
try:
if not os.path.isdir(spSrc):
print("Folder <"+spSrc+"> not found. Can’t move files.")
return
if not os.path.isdir(spDst)
print("Folder <"+spDst+"> not found. Can’t move files.")
return
for sf in os.listdir(spSrc):
spfSrc = os.path.join(spSrc, sf)
if os.path.isfile(spfSrc):
spfDst = os.path.join(spDst, sPrefix + sf)
shutil.move(spfSrc, spfDst)
if bLog:
print("file <" + spfSrc + "> moved to <"+spfDst+">")
|