import os 
import shutil
from pathlib  import Path 


SRC_DIR = "/mnt/ssd1T/hoanglv/Projects/KIE/DATA/dev_model/Receipt/processed/train/sbt/batch_1"
TEST_DIR = "/mnt/ssd1T/tuanlv/06.KVUCombineStage/datasets/invoices-receipts/SS_invoices/SBT/validation_data/images"
OUT_DIR = "/mnt/ssd1T/hoanglv/Projects/KIE/DATA/dev_model/Receipt/processed/test_sbt"

# Get a list of all the files in the test directory
test_files = [Path(f).name for f in os.listdir(TEST_DIR) if ".txt" not in f]

# Create the output directory if it doesn't exist
os.makedirs(OUT_DIR, exist_ok=True)

# Move the matching files from the source directory to the output directory
for filename in os.listdir(SRC_DIR):
    if Path(filename).name in test_files:
        src_path = os.path.join(SRC_DIR, filename)
        # out_path = os.path.join(OUT_DIR, filename)
        shutil.move(src_path, OUT_DIR)

        #move .txt 
        src_txt_path = Path(os.path.join(SRC_DIR, filename)).with_suffix(".txt")
        shutil.move(str(src_txt_path), OUT_DIR)