Export and Import
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import sys
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
from config import IMPORT_DIR
|
||||
|
||||
def sync_annotated(dir_arg, refaire):
|
||||
if not refaire:
|
||||
bgnot_dir = Path(dir_arg) / "BGnot"
|
||||
else:
|
||||
bgnot_dir = Path(dir_arg) / "BRnot"
|
||||
|
||||
annotated_dir = IMPORT_DIR
|
||||
|
||||
if not annotated_dir.is_dir():
|
||||
print(f"Error: Directory {annotated_dir} does not exist.")
|
||||
return
|
||||
|
||||
# Iterate over all PDF files in the annotated directory
|
||||
for pdf_file in annotated_dir.glob("*.pdf"):
|
||||
subdir_name = pdf_file.stem # 'f' from 'f.pdf'
|
||||
target_subdir = bgnot_dir / subdir_name
|
||||
|
||||
if not target_subdir.is_dir():
|
||||
print(f"Warning: Directory {target_subdir} not found.")
|
||||
else:
|
||||
dest_file = target_subdir / "Concat_annotated.pdf"
|
||||
print("copying ", pdf_file, " to ", dest_file)
|
||||
shutil.copy2(pdf_file, dest_file)
|
||||
|
||||
import argparse
|
||||
|
||||
|
||||
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
|
||||
|
||||
sync_annotated(root_dir, args.refaire)
|
||||
Reference in New Issue
Block a user