Replies: 1 comment
|
fd can run a command for every match, but it is not a faster replacement for this directory-merge operation. The expensive part is moving/copying filesystem entries, not discovering them, and parallel mv calls introduce ordering and collision problems: destination directories must exist first, two sources may share a basename, and cross-filesystem moves become copies. For the semantics in the gist, use rsync, which already implements recursive directory merging and preserves metadata: Keep a backup or add --dry-run while testing conflict behavior. Decide explicitly whether an existing destination file should be overwritten; add --ignore-existing if it should not. If you still want fd for filtering files inside one source tree, -x/--exec invokes once per result and -X/--exec-batch invokes once with all results. Its placeholders include {} (path), {/} (basename), and {//} (parent), documented in the command execution section. But fd does not provide an atomic merge-tree primitive, so using it here adds complexity without making the moves themselves faster. If rsync --remove-source-files matches the intended merge behavior, please mark this as accepted. |
Uh oh!
There was an error while loading. Please reload this page.
The code in question is here. You call the command and provide the full paths to files or folders, then it moves and merges them with your current directory (It's done this way because it's for use with the terminal file manager lf).
It works in find but since I also want it to be fast I want to rewrite it in fd. Can it be done? Is it worth the hassle?
All reactions