diff --git a/yazi-shared/src/fs/path.rs b/yazi-shared/src/fs/path.rs index 592e4f17..dd8343e0 100644 --- a/yazi-shared/src/fs/path.rs +++ b/yazi-shared/src/fs/path.rs @@ -100,9 +100,19 @@ pub async fn unique_name(mut u: Url) -> io::Result { let mut name = OsString::with_capacity(stem.len() + ext.len() + 5); name.push(&stem); - name.push("_"); - name.push(i.to_string()); - name.push(&ext); + + // Check if it's a directory + if p.is_dir() { + // For directories, append the index at the end + name.push("_"); + name.push(i.to_string()); + name.push(&ext); + } else { + // For files, keep the existing behavior + name.push("_"); + name.push(i.to_string()); + name.push(&ext); + } p.set_file_name(name); i += 1;