fix NAS mounts
This commit is contained in:
@@ -13,6 +13,7 @@ checkpoint model and LoRA names, and moves files into:
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import sys
|
||||
import time
|
||||
from pathlib import Path
|
||||
@@ -355,12 +356,23 @@ def sanitize_dir_name(name):
|
||||
|
||||
# ── main ───────────────────────────────────────────────────────────────────
|
||||
|
||||
def nas_mount_base():
|
||||
"""Return the NAS mount base path for this machine."""
|
||||
candidates = [
|
||||
"/mini.nas/miniShare1",
|
||||
os.path.expanduser("~/mnt/mini.nas/miniShare1"),
|
||||
os.path.expanduser("~/mnt/miniShare1"),
|
||||
]
|
||||
for p in candidates:
|
||||
if os.path.isdir(p):
|
||||
return p
|
||||
return candidates[-1]
|
||||
|
||||
|
||||
def main():
|
||||
import argparse
|
||||
|
||||
DEFAULT_OUTPUT = os.path.expanduser(
|
||||
"~/mnt/mini.nas/miniShare1/Pictures/Images/AI"
|
||||
)
|
||||
DEFAULT_OUTPUT = os.path.join(nas_mount_base(), "Pictures", "Images", "AI")
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Scan PNGs for AI prompt metadata and reorg into model/lora folders.",
|
||||
@@ -518,10 +530,10 @@ def main():
|
||||
new_path = new_path.with_name(f"{stem}_{counter}{new_path.suffix}")
|
||||
counter += 1
|
||||
try:
|
||||
old_path.rename(new_path)
|
||||
shutil.move(old_path, new_path)
|
||||
moved += 1
|
||||
except FileNotFoundError:
|
||||
print(f" SKIPPED (not found): {old_path.name}")
|
||||
except (FileNotFoundError, OSError) as e:
|
||||
print(f" SKIPPED ({e}): {old_path.name}")
|
||||
print(f" Moved {moved} file(s)." if not args.dry_run else "")
|
||||
else:
|
||||
moved = 0
|
||||
@@ -584,9 +596,9 @@ def main():
|
||||
np = np.with_name(f"{stem}_{counter}{np.suffix}")
|
||||
counter += 1
|
||||
try:
|
||||
p.rename(np)
|
||||
except FileNotFoundError:
|
||||
print(f" SKIPPED (not found): {p.name}")
|
||||
shutil.move(p, np)
|
||||
except (FileNotFoundError, OSError) as e:
|
||||
print(f" SKIPPED ({e}): {p.name}")
|
||||
moved += len(items) - i
|
||||
break
|
||||
else:
|
||||
@@ -606,10 +618,10 @@ def main():
|
||||
counter += 1
|
||||
print(f" (file existed, saved as {new_path.name})")
|
||||
try:
|
||||
old_path.rename(new_path)
|
||||
shutil.move(old_path, new_path)
|
||||
moved += 1
|
||||
except FileNotFoundError:
|
||||
print(f" SKIPPED (not found): {old_path.name}")
|
||||
except (FileNotFoundError, OSError) as e:
|
||||
print(f" SKIPPED ({e}): {old_path.name}")
|
||||
i += 1
|
||||
|
||||
print(f"\n Moved: {moved} Skipped: {skipped}")
|
||||
|
||||
Reference in New Issue
Block a user