review page, fix rename bug

This commit is contained in:
Julian Freeman
2025-12-07 19:56:26 -04:00
parent 930f3c40fa
commit 05ef56a69b

View File

@@ -205,6 +205,20 @@ fn rename_videos(files: Vec<String>, prefix: String, base_name: String) -> Resul
// Rename files in this directory // Rename files in this directory
let mut current_index = 1; let mut current_index = 1;
for file_path in file_list { 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 // Find next available index
while occupied_indices.contains(&current_index) { while occupied_indices.contains(&current_index) {
current_index += 1; current_index += 1;