Rudimentary support for --refaire
This commit is contained in:
+25
-5
@@ -44,9 +44,29 @@ def process_directory(dir_arg):
|
||||
# Création du lien symbolique (pointe vers le chemin absolu pour éviter les problèmes)
|
||||
os.link(concat_file.absolute(), symlink_path)
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage: python script.py <dir>")
|
||||
sys.exit(1)
|
||||
import argparse
|
||||
|
||||
process_directory(sys.argv[1])
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="Move to tablette folder.")
|
||||
parser.add_argument("dir", help="The directory to process")
|
||||
parser.add_argument("--refaire", action="store_true", help="Process only copies/labels defined in refaire.json")
|
||||
|
||||
args = parser.parse_args()
|
||||
root_dir = args.dir
|
||||
|
||||
if args.refaire:
|
||||
base_dir = Path(root_dir)
|
||||
brnot_dir = base_dir / "BRnot"
|
||||
sync_dir = Path.home() / "SyncCopies" / "À Annoter" / root_dir
|
||||
sync_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
for f in brnot_dir.iterdir():
|
||||
concat_file = f / "Concat.pdf"
|
||||
if f.is_dir() and concat_file.is_file():
|
||||
symlink_path = sync_dir / f"{f.name}.pdf"
|
||||
if symlink_path.exists():
|
||||
symlink_path.unlink()
|
||||
os.link(concat_file.absolute(), symlink_path)
|
||||
sys.exit(0)
|
||||
else:
|
||||
process_directory(root_dir)
|
||||
|
||||
Reference in New Issue
Block a user