mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
feat: give indication to original filenames in bulk rename
This commit is contained in:
parent
e138364102
commit
1ca98cc875
1 changed files with 9 additions and 2 deletions
|
|
@ -26,12 +26,16 @@ impl Mgr {
|
|||
tokio::spawn(async move {
|
||||
let tmp = YAZI.preview.tmpfile("bulk");
|
||||
let s = old.iter().map(|o| o.as_os_str()).collect::<Vec<_>>().join(OsStr::new("\n"));
|
||||
const DIVIDER: &str = "\n<↑ After ↑> <↓ Before ↓>\n";
|
||||
|
||||
let content = [&s, OsStr::new(&format!("{}", DIVIDER)), &s].join(OsStr::new(""));
|
||||
|
||||
OpenOptions::new()
|
||||
.write(true)
|
||||
.create_new(true)
|
||||
.open(&tmp)
|
||||
.await?
|
||||
.write_all(s.as_encoded_bytes())
|
||||
.write_all(content.as_encoded_bytes())
|
||||
.await?;
|
||||
|
||||
defer! { tokio::spawn(fs::remove_file(tmp.clone())); }
|
||||
|
|
@ -45,7 +49,10 @@ impl Mgr {
|
|||
defer!(AppProxy::resume());
|
||||
AppProxy::stop().await;
|
||||
|
||||
let new: Vec<_> = fs::read_to_string(&tmp).await?.lines().map(PathBuf::from).collect();
|
||||
let content = fs::read_to_string(&tmp).await?;
|
||||
|
||||
let new: Vec<_> =
|
||||
content.split(DIVIDER).next().unwrap_or("").lines().map(PathBuf::from).collect();
|
||||
Self::bulk_rename_do(root, old, new).await
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue