review page, fix rename bug
This commit is contained in:
@@ -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(¤t_index) {
|
while occupied_indices.contains(¤t_index) {
|
||||||
current_index += 1;
|
current_index += 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user