ayoisaiah / f2

F2 is a cross-platform command-line tool for batch renaming files and directories quickly and safely. Written in Go!
https://f2.freshman.tech
MIT License
866 stars 38 forks source link

Feature idea - Set working directory #61

Closed seb26 closed 3 months ago

seb26 commented 8 months ago

Feature request

Add the option to specify a directory for f2 to work in. But by default continue the current behaviour and work in the cwd.

Background

Right now as far as I can see (using macOS 14.2 and f2 from brew), f2 operates on the current working directory or a csv list of files.

This would help me run the program to work over a particular directory without having to worry about CDing in a separate command beforehand, and it therefore becomes less complex and less error prone to implement in certain automation scenarios of mine. Like as a hypothetical, in a script if the cd fails and it doesn't change working directory then it runs f2 in an unintended working directory.

Something like:

f2 /Volumes/path_to_media/ -f "pattern"

In lieu of:

cd /Volumes/path_to_media/
f2 -f "pattern"
seb26 commented 8 months ago

Hey ayoisaiah I see you're already familiar with this idea from https://github.com/ayoisaiah/f2/issues/55#issuecomment-1793759976.

I like the suggestion to pipe files to it from find, but I put forth my vote for a dedicated directory path directly in f2.

ayoisaiah commented 8 months ago

@seb26 Absolutely, this makes sense and will be easy to add. I'll do my best to get to it soon :)

ayoisaiah commented 3 months ago

@seb26 You can already specify one or more working directories after all options:

f2 FLAGS [OPTIONS] [PATHS TO FILES AND DIRECTORIES...]

In your case, this will be:

f2 -f "pattern" /Volumes/path_to_media/ 

I think I misunderstood this request the first time I read it, as this has always been possible in F2.