YongchengYAO commited on
Commit
853dbfd
·
1 Parent(s): cd62b71

minor update: move_folder()

Browse files
src/medvision_ds/utils/preprocess_utils.py CHANGED
@@ -70,7 +70,15 @@ def move_folder(source_folder, destination_folder, create_dest=True):
70
  for item in os.listdir(source_folder):
71
  s = os.path.join(source_folder, item)
72
  d = os.path.join(destination_folder, item)
73
- shutil.move(s, d)
 
 
 
 
 
 
 
 
74
  else:
75
  # If destination doesn't exist, move the entire folder
76
  shutil.move(source_folder, destination_folder)
 
70
  for item in os.listdir(source_folder):
71
  s = os.path.join(source_folder, item)
72
  d = os.path.join(destination_folder, item)
73
+ if os.path.isdir(s) and os.path.isdir(d):
74
+ # Merge contents instead of nesting directory
75
+ for sub_item in os.listdir(s):
76
+ ss = os.path.join(s, sub_item)
77
+ dd = os.path.join(d, sub_item)
78
+ shutil.move(ss, dd)
79
+ os.rmdir(s)
80
+ else:
81
+ shutil.move(s, d)
82
  else:
83
  # If destination doesn't exist, move the entire folder
84
  shutil.move(source_folder, destination_folder)