-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPREPARE_LV200_SUBFOLDER_STRUCTURE.py
53 lines (45 loc) · 1.82 KB
/
PREPARE_LV200_SUBFOLDER_STRUCTURE.py
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# -*- coding: utf-8 -*-
"""
Created on Fri Apr 23 13:21:49 2021
@author: Martin.Sladek
Creates structure of subdirectories for analysis of LV200 data
"""
import os, shutil
from tkinter import filedialog
from tkinter import *
# Desired name of the sample folder:
folderid = 'SCN'
# Desired names of the subregions (e.g. SCN Left and Right)
subregions = ['L', 'R']
# Desired names of the subfolders (e.g. SCN before and after treatment)
subdirectories = ['before', 'after']
# Total number of folders (e.g. analyzed SCNs)
total_no = 6
# Want specific sample names? Use custom list and comment out default list_of_samples
list_of_samples = [5,6]
#list_of_samples = range(1, total_no + 1)
##################### Tkinter button for browse/set_dir ################################
def browse_button():
global folder_path # Allow user to select a directory and store it in global var folder_path
filename = filedialog.askdirectory()
folder_path.set(filename)
print(filename)
sourcePath = folder_path.get()
os.chdir(sourcePath) # Provide the path here
root.destroy() # close window after pushing button
# Specify FOLDER BEFORE TREATMENT
root = Tk()
folder_path = StringVar()
lbl1 = Label(master=root, textvariable=folder_path)
lbl1.grid(row=0, column=1)
buttonBrowse = Button(text="Browse to parental folder", command=browse_button)
buttonBrowse.grid()
mainloop()
path = os.getcwd() + '\\'
newfolders = []
for directories in list_of_samples:
for subregion in subregions:
for subdirectory in subdirectories:
mydir_no = os.path.join(os.getcwd(), f'{folderid}{directories}{subregion}\\{subdirectory}')
os.makedirs(mydir_no)
newfolders.append(mydir_no)