sxyazi/yazi · error
Invalid new or old file name
Error message
Invalid new or old file name
What it means
In bulk_rename r#do, each old/new (Optimizely-style) entry is turned into full URLs via replace_url, which requires valid UTF-8/naming. If either conversion fails, the pair is recorded as failed with "Invalid new or old file name" and the batch continues with the rest.
Solutions
- Sanitize the new names (ensure non-empty, valid UTF-8, no path separators) before invoking bulk_rename.
- Inspect the old files' names for non-UTF-8 bytes and fix them first.
- Test the rename mapping with a single entry to isolate the offending name.
Example fix
// before
{ from: "file\xFF", to: "" }
// after
{ from: "file", to: "renamed-file" } Defensive patterns
Strategy: validation
Validate before calling
-- Lua, before bulk_rename
local function valid_name(n)
return type(n) == "string" and #n > 0 and not n:find("[/\\0]") and utf8 and utf8.len(n) ~= nil
end
assert(valid_name(new_name), "new name must be a non-empty valid name") Prevention
- Sanitize regex-substitution output (drop empty results).
- Reject names with path separators or NUL bytes.
- Verify UTF-8 validity of names sourced from external data.
When it happens
Trigger: replace_url returns Err for either the old or the new name — e.g. non-UTF-8 text, empty name, or a name that violates URL/path construction rules.
Common situations: Bulk rename input from external sources containing invalid bytes; empty replacement names from a regex substitution; filenames with invalid characters pasted from the clipboard.
Related errors
- empty file stem
- at least one of `url` or `mime` must be specified
- Cache stamp does not match entry
- Cache stamp does not match target
- Cannot construct system event
AI-assisted analysis of sxyazi/yazi@8ebf930f17 (2026-09-02).
Data as JSON: /api/errors/a926b063b74722b0.
Report an issue: GitHub.
Appendix: source
Thrown at yazi-actor/src/mgr/bulk_rename.rs:121
}
let (old, new) = old.into_iter().zip(new).filter(|(o, n)| o != n).unzip();
let todo = Self::prioritized_paths(old, new);
if todo.is_empty() {
return Ok(());
}
if !Self::ask_continue(&todo, decision)? {
return Ok(());
}
let permit = WATCHER.acquire().await.unwrap();
let (mut failed, mut succeeded) = (Vec::new(), HashMap::with_capacity(todo.len()));
for (o, n) in todo {
let (Ok(old), Ok(new)) =
(Self::replace_url(&selected[o.0], root, &o), Self::replace_url(&selected[n.0], root, &n))
else {
failed.push((o, n, anyhow!("Invalid new or old file name")));
continue;
};
if maybe_exists(&new).await && !engine::must_identical(&old, &new).await {
failed.push((o, n, anyhow!("Destination already exists")));
} else if let Err(e) = engine::rename(&old, &new).await {
failed.push((o, n, e.into()));
} else if let Ok(f) = engine::file(new).await {
succeeded.insert(old, f);
} else {
failed.push((o, n, anyhow!("Failed to retrieve file info")));
}
}
if !succeeded.is_empty() {
let it = succeeded.iter().map(|(o, n)| (o.as_url(), n.url.as_url()));
log_if_err!(Pubsub::pub_after_bulk_rename(it));
FilesOp::rename(succeeded);View on GitHub (pinned to 8ebf930f17)