-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubSimulationRecounter.py
More file actions
37 lines (28 loc) · 1.14 KB
/
subSimulationRecounter.py
File metadata and controls
37 lines (28 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import os
import shutil
def copyAndRenameFolders(sourceDir, constant):
destinationDir = os.path.join(sourceDir, '_renamed')
os.makedirs(destinationDir, exist_ok=True)
for root, dirs, files in os.walk(sourceDir):
if '_renamed' in dirs:
dirs.remove('_renamed')
for dirName in dirs:
folderName = dirName.split('_')
if len(folderName) != 2:
continue
int1, int2 = folderName
try:
int1 = int(int1)
int2 = int(int2)
except ValueError:
continue
newInt2 = int2 + constant
newFolderName = f"{int1}_{newInt2}"
sourcePath = os.path.join(root, dirName)
destinationPath = os.path.join(destinationDir, newFolderName)
shutil.copytree(sourcePath, destinationPath)
print(f"Folder '{dirName}' copied and renamed to '{newFolderName}'.")
# Example usage
sourceDirectory = r"E:\simulationdata\multiple_groups\nematic\va_over_eta_multiple_groups_58fc0010-5052-46e8-b0d0-b2ad976a489b"
constant = 100
copyAndRenameFolders(sourceDirectory, constant)