-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathquick_leftovers.py
More file actions
53 lines (41 loc) · 1.69 KB
/
Copy pathquick_leftovers.py
File metadata and controls
53 lines (41 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import os
import shutil
import pandas as pd
# Configuration - modify these paths
csv_path = r"S:\qfl_australia_tls\Curtain Fig\trees_within_plot.csv"
source_folder = r"S:\qfl_australia_tls\Curtain Fig\output"
leftover_folder = r"S:\qfl_australia_tls\Curtain Fig\leftover_trees"
# Create leftover folder if it doesn't exist
os.makedirs(leftover_folder, exist_ok=True)
# Get CSV filenames (files to skip)
df = pd.read_csv(csv_path)
csv_filenames = set(df['filename'].tolist())
# Get all files in source
all_files = [f for f in os.listdir(source_folder) if os.path.isfile(os.path.join(source_folder, f))]
# Get already processed leftovers
already_leftover = set(os.listdir(leftover_folder)) if os.path.exists(leftover_folder) else set()
print(f"Total files in source: {len(all_files)}")
print(f"Files in CSV (to skip): {len(csv_filenames)}")
print(f"Already in leftover folder: {len(already_leftover)}")
copied = 0
skipped = 0
# Copy only leftover files (not in CSV, not already processed)
for file_name in all_files:
if file_name in csv_filenames:
# Skip - this file is in the selection CSV
continue
if file_name in already_leftover:
# Skip - already copied to leftover folder
skipped += 1
continue
# Copy to leftover folder
source_path = os.path.join(source_folder, file_name)
dest_path = os.path.join(leftover_folder, file_name)
try:
shutil.copy2(source_path, dest_path)
copied += 1
if copied % 100 == 0:
print(f"Copied {copied} files...")
except Exception as e:
print(f"Error copying {file_name}: {e}")
print(f"\nDone! Copied {copied} new leftover files, skipped {skipped} already processed")