Skip to content

Commit c9d945a

Browse files
Add fix recursive option & checkbox
1 parent 021b207 commit c9d945a

File tree

3 files changed

+55
-9
lines changed

3 files changed

+55
-9
lines changed

DAZFix/RecursiveChecker.py

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,32 @@
33
import shutil
44

55

6+
def check_recursive(library_path):
7+
dupe_folders = []
8+
for (root, dirs, files) in os.walk(library_path, topdown=True):
9+
for dir in dirs:
10+
full_directory = os.path.join(root,dir)
11+
# if current_depth > previous_depth and os.path.basename(os.path.normpath(full_directory)) == previous_root_end_folder:
12+
if os.path.basename(os.path.normpath(root)) == os.path.basename(os.path.normpath(full_directory)):
13+
log_to_ui("WARNING: Folder appears to have been placed inside itself:")
14+
log_to_ui(f"Current full path: {full_directory}")
15+
16+
# FIX #
17+
# Note the top-level folder
18+
# top_folder = root
19+
dupe_folder_name = os.path.basename(os.path.normpath(root))
20+
21+
# Walk from this folder to find out how many matryoshka folders we have
22+
for (root2, dirs2, files2) in os.walk(root, topdown=True):
23+
# Iterate over the directories for this level/root
24+
for d in dirs2:
25+
full_dir_path = os.path.join(root2,d)
26+
# Mark dupe folders with the same name as the current ("parent") folder
27+
if os.path.basename(os.path.normpath(d)) == dupe_folder_name:
28+
log_to_ui(f"Nested folder found:\n{full_dir_path}")
29+
30+
31+
632
def fix_recursive(library_path):
733
dupe_folders = []
834
for (root, dirs, files) in os.walk(library_path, topdown=True):
@@ -81,13 +107,20 @@ def fix_recursive(library_path):
81107
return True
82108

83109

84-
def check(library_path):
110+
def check(library_path, fix_folders):
85111
complete = False
86112
counter = 1
87-
while not complete:
88-
log_to_ui(f"Checking {library_path} for recursive folders, iteration {counter}-------------------------------------------------------")
89-
complete = fix_recursive(library_path)
90-
counter += 1
91113

92-
log_to_ui("Done fixing recursive folders!")
114+
if fix_folders:
115+
while not complete:
116+
log_to_ui(f"Checking {library_path} for recursive folders, iteration {counter}-------------------------------------------------------")
117+
complete = fix_recursive(library_path)
118+
counter += 1
119+
log_to_ui("Done fixing recursive folders!")
120+
else:
121+
check_recursive(library_path)
122+
log_to_ui("Done checkin recursive folders!")
123+
return True
124+
125+
93126

daz_linux_casefix.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def __init__(self):
3636

3737
self.ui.btnSavePaths.clicked.connect(self.save_paths)
3838

39-
self.ui.btnRecursive.clicked.connect(lambda: check(self.ui.txtUserPath.text()))
39+
self.ui.btnRecursive.clicked.connect(lambda: check(self.ui.txtUserPath.text(), self.ui.chkRecursive.isChecked()))
4040

4141

4242

@@ -166,6 +166,6 @@ def fix_directories(self):
166166
app.setStyleSheet(qdarktheme.load_stylesheet())
167167

168168
print(app.style().objectName())
169-
AnachronoxDATUI = DAZWranglerApp()
169+
App = DAZWranglerApp()
170170

171171
sys.exit(app.exec())

daz_linux_casefix.ui

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@
199199
<widget class="QPushButton" name="btnRecursive">
200200
<property name="geometry">
201201
<rect>
202-
<x>230</x>
202+
<x>760</x>
203203
<y>320</y>
204204
<width>321</width>
205205
<height>32</height>
@@ -209,6 +209,19 @@
209209
<string>Check User Library For Recursive Folders</string>
210210
</property>
211211
</widget>
212+
<widget class="QCheckBox" name="chkRecursive">
213+
<property name="geometry">
214+
<rect>
215+
<x>760</x>
216+
<y>290</y>
217+
<width>211</width>
218+
<height>20</height>
219+
</rect>
220+
</property>
221+
<property name="text">
222+
<string>Fix Recursive Folders On Check</string>
223+
</property>
224+
</widget>
212225
</widget>
213226
<widget class="QWidget" name="tab_2">
214227
<attribute name="title">

0 commit comments

Comments
 (0)