This commit is contained in:
Ross
2026-07-07 17:25:06 +01:00
parent 97898e14d2
commit 460ea1af57
1881 changed files with 51988 additions and 161 deletions
+11
View File
@@ -189,6 +189,7 @@ def main(argv=None):
p.add_argument('--out', default='results.json', help='Output file')
p.add_argument('--format', choices=['json','csv'], default='json')
p.add_argument('--copy-to', help='Optional: copy matched markdown files to this dir')
p.add_argument("--copy-to-clear", default=True, action="store_true", help="Overwrite files when copying to --copy-to")
args = p.parse_args(argv)
if ':' not in args.query:
@@ -204,6 +205,16 @@ def main(argv=None):
if args.copy_to and results:
os.makedirs(args.copy_to, exist_ok=True)
if args.copy_to_clear:
# clear existing files in target dir
for existing_fn in os.listdir(args.copy_to):
existing_path = os.path.join(args.copy_to, existing_fn)
try:
if os.path.isfile(existing_path):
os.remove(existing_path)
except Exception:
pass
for r in results:
try:
dst = os.path.join(args.copy_to, os.path.basename(r['path']))