From 05ef56a69b26b1b469099d3fe91e38309126f182 Mon Sep 17 00:00:00 2001 From: Julian Freeman Date: Sun, 7 Dec 2025 19:56:26 -0400 Subject: [PATCH] review page, fix rename bug --- src-tauri/src/lib.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 6f033ad..620478d 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -205,6 +205,20 @@ fn rename_videos(files: Vec, prefix: String, base_name: String) -> Resul // Rename files in this directory let mut current_index = 1; for file_path in file_list { + // Check if the file already matches the desired format + if let Some(file_name) = file_path.file_name().and_then(|n| n.to_str()) { + let name_without_ext = Path::new(file_name).file_stem().and_then(|s| s.to_str()).unwrap_or(""); + let prefix_base = format!("{}{}", prefix, base_name); + + if name_without_ext.starts_with(&prefix_base) { + let suffix = &name_without_ext[prefix_base.len()..]; + // If it ends with 2 digits, it's already named correctly + if suffix.len() == 2 && suffix.chars().all(|c| c.is_digit(10)) { + continue; // Skip this file + } + } + } + // Find next available index while occupied_indices.contains(¤t_index) { current_index += 1;