Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include a --depth option #1356

Open
muellerj opened this issue Aug 1, 2023 · 1 comment
Open

Include a --depth option #1356

muellerj opened this issue Aug 1, 2023 · 1 comment

Comments

@muellerj
Copy link

muellerj commented Aug 1, 2023

First of all thanks for a great tool!

For renaming nested files/folders, find(1) has a -depth option which traverses the file-system in a depth-first order in order to avoid trying to rename an item in an already renamed folder:

# Rename all files and folders containing "_foo" by replacing "_foo" -> "_bar"
find . -iname _foo -depth -exec rename _foo _bar '{}' \;

Any chance of having a similar option for fd?

See: https://man7.org/linux/man-pages/man1/find.1.html#EXPRESSION

I've seen that there has been some discussion about breadth first/depth first traversal already - thank you for your consideration.

@dbohdan
Copy link

dbohdan commented Jan 18, 2025

The readme currently carries the following note about deleting files:

There are scenarios where using fd … -X rm -r can cause race conditions: if you have a path like …/foo/bar/foo/… and want to remove all directories named foo, you can end up in a situation where the outer foo directory is removed first, leading to (harmless) "'foo/bar/foo': No such file or directory" errors in the rm call.

If this option was implemented, it seems like the note could be replaced with a recommendation to use fd … --depth -X rm -r.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants