Skip to content

Reference capture groups inside exec #1154

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

Open
BasixKOR opened this issue Nov 1, 2022 · 3 comments
Open

Reference capture groups inside exec #1154

BasixKOR opened this issue Nov 1, 2022 · 3 comments

Comments

@BasixKOR
Copy link

BasixKOR commented Nov 1, 2022

I'd like to rename a bulk of files using fd but I'd like to use some parts of the original filename in the renamed filenames.

Could we add something like:

fd '(\d+)' -X mv {} something-{1}
@sharkdp
Copy link
Owner

sharkdp commented Nov 1, 2022

Looks like you might be interested in the discussion/draft in #1118

@BasixKOR
Copy link
Author

BasixKOR commented Nov 2, 2022

Oops, I haven't looked into PRs. No wonder why issue search yielded no results... I'll keep this issue for discoverability and tracking purposes, but feel free to close it if you don't think it's needed.

@cclifford
Copy link

cclifford commented Aug 28, 2023

I would also like a feature like this, but I have a different use case. I do data science at a university and use fd to select data files from a large directory hierarchy of related data. The file paths often contain metadata like the name of the sensor it came from. We usually need to pass metadata from the path to our data processing scripts, so I usually execute a little bash wrapper script to parse it out and call the script.

Anyway, there are use cases where information from the file path needs to be used in conjunction with the file itself, other than renaming.

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

3 participants