From f8d9c812881c4138da5bb9c960881de8e6e97b37 Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Sat, 17 Jan 2026 15:03:18 +0100 Subject: [PATCH] Update tab_category_sorter.py --- tab_category_sorter.py | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/tab_category_sorter.py b/tab_category_sorter.py index 1f3ddbc..ad6bd44 100644 --- a/tab_category_sorter.py +++ b/tab_category_sorter.py @@ -9,46 +9,29 @@ def render(path_t, path_out, quality, naming_mode): if st.session_state.idx_cat < len(images): curr_p = os.path.join(path_t, images[st.session_state.idx_cat]) - # Filmstrip (Current + Next 6) + # Filmstrip st.write("### 🎞️ Filmstrip") fs_cols = st.columns(7) for i, img_name in enumerate(images[st.session_state.idx_cat : st.session_state.idx_cat + 7]): fs_cols[i].image(SorterEngine.compress_for_web(os.path.join(path_t, img_name), 10)) - st.divider() - col_img, col_btns = st.columns([2, 1]) - col_img.image(SorterEngine.compress_for_web(curr_p, quality), caption=images[st.session_state.idx_cat]) + col_img.image(SorterEngine.compress_for_web(curr_p, quality)) with col_btns: fid = SorterEngine.get_folder_id(path_t) - st.write(f"**Current Folder ID:** {fid}") - - # Category Management - new_cat = st.text_input("➕ New Category") - if st.button("Add"): SorterEngine.add_category(new_cat); st.rerun() - - # Dynamic Category Buttons + st.write(f"**Folder ID:** {fid}") for cat in categories: if st.button(cat, use_container_width=True): - # Naming Logic from script _, ext = os.path.splitext(curr_p) name = images[st.session_state.idx_cat] if naming_mode == "original" else f"{fid}{ext}" - dst_dir = os.path.join(path_out, cat) os.makedirs(dst_dir, exist_ok=True) dst_p = os.path.join(dst_dir, name) - - # Collision check - count = 2 - while os.path.exists(dst_p): - root, ext = os.path.splitext(name) - dst_p = os.path.join(dst_dir, f"{root}_{count}{ext}") - count += 1 - shutil.move(curr_p, dst_p) - st.toast(f"Moved to {cat}") + st.session_state.history.append({'type': 'cat_move', 't_src': curr_p, 't_dst': dst_p}) st.rerun() - - if st.button("⏭️ SKIP", type="secondary", use_container_width=True): - st.session_state.idx_cat += 1; st.rerun() \ No newline at end of file + if st.button("SKIP"): + st.session_state.idx_cat += 1 + st.rerun() + else: st.success("Finished Categorizing.") \ No newline at end of file