https://github.com/ayoisaiah/f2
F2 is a cross-platform command-line tool for batch renaming files and directories quickly and safely. Written in Go!
I downloaded an already compiled binary from:
Moderator: Forum moderators
https://github.com/ayoisaiah/f2
F2 is a cross-platform command-line tool for batch renaming files and directories quickly and safely. Written in Go!
I downloaded an already compiled binary from:
@muggins Nice find! Did you try it?
This is an incredibly powerful renaming tool and certainly deserves some attention
1) Only 1 binary file
2) Works nicely in my ancient Slacko 5.6
3) Still actively developed
4) Well documented with many examples
As all command line tools it lacks some user friendliness and requires to study the syntax, but that's a small price to pay. It can rename files in a way no other renaming tool I've ever seen can.
What Puppy users may miss is the possibility to rename files selected in ROX-Filer. However this could be done with a script that takes a ROX-Filer selection as input.
Hello MochiMoppel,
I only gave it a short test, just to check it works in my pupversion. But, yes, it is fast & powerful & it would be
good if someone could write a frontend for it.
New version:
1.8.0 (2022-02-22)
Add a "simple mode" for quick renaming operations in the current directory.
1.9.0 (2023-02-02)
Simple mode now prompts before executing.
You can now use capture variables with indexing.
A simple mode example: f2 '\.jpg$' .jpeg
Edit: Hopefully a less funny example. The good thing is that it's possible to undo funny results of the latest f2 command with f2 -ux
.
Edit 2: New version: 1.9.0
Hi there. How do I install it? Do I download the deb package?
Fossapup64 9.5
If you download https://github.com/ayoisaiah/f2/release ... d64.tar.gz then you can extract the f2 binary. To have it it your path, just move it to /usr/bin/
Edit: I changed the link from the development release to the stable version.
Looks good.
For more complex renaming tasks like renumbering etc I have tried MultiRename which is OOTB in Bookwormpup64 under the Filesystem menu.
Worth trying.
In fact f2 is designed for more complex renaming tasks.
It's a new version again - 2.0.1
Good news: the natural sorting has finally been added.
Bad news: it has a bug/regression that prevents replacing spaces with underscores or vice versa. f2 -f " " -r "_"
doesn't work anymore.
The reason is simple: f2 now uses github.com/urfave/cli for its argument parsing. The bug in that lib has been fixed but with an optional switch that has to be added to the f2 code. Unfortunately, I know nothing about go programming and don't have a github account to report the bug. So, we need to wait till someone else finds and reports it.
It's actually very easy to fix:
download the f2-2.0.1 source package, apply the following to the app/flag.go:
Code: Select all
23a24
> KeepSpace: true,
33a35
> KeepSpace: true,
and compile.
Burunduk wrote: Fri Nov 22, 2024 10:24 amBad news: it has a bug/regression that prevents replacing spaces with underscores or vice versa.
f2 -f " " -r "_"
doesn't work anymore.
Replacing spaces with underscores works when using octal instead of literal space : f2 -f '\40' -r '_'
, however replacing underscores with spaces seems not to work.
More good news: For such trivial task the rename tool might be easier to use: rename -a ' ' '_'
. It even works - both ways
MochiMoppel wrote: Fri Nov 22, 2024 12:34 pmBurunduk wrote: Fri Nov 22, 2024 10:24 amBad news: it has a bug/regression that prevents replacing spaces with underscores or vice versa.
f2 -f " " -r "_"
doesn't work anymore.Replacing spaces with underscores works when using octal instead of literal space :
f2 -f '\40' -r '_'
, however replacing underscores with spaces seems not to work.
More good news: For such trivial task the rename tool might be easier to use:rename -a ' ' '_'
. It even works - both ways
It even doesn't work at all here:
Code: Select all
# rename -a ' ' '_'
rename: invalid option -- 'a'
Try 'rename --help' for more information.
A different rename
I guess. But what are you trying to say? That it's not a bug? Or that it is, but isn't worth fixing if so many workarounds are possible? Or just want to say something in spite?
By the way, this trivial task is just an example. Any leading or trailing spaces are trimmed from both strings. This is at least unexpected I think.
It is a bug.
Or that it is, but isn't worth fixing if so many workarounds are possible?
It is worth fixing, of course!
Or just want to say something in spite?
Did I say something offending?
I downloaded the f2_2.0.1_linux_amd64.deb and installed in BookwormPup64 10.0.8
Left click on it to install.
It places everything in the file system where it needs to be.
Run from terminal
Code: Select all
f2
The things you do not tell us, are usually the clue to fixing the problem.
When I was a kid, I wanted to be older.
This is not what I expected
@MochiMoppel
No offense, of course. Just failed to spot an evidence of constructive approach in your initial reaction. Thanks for the clarification.
I've found f2 to be a very useful tool. Otherwise I wouldn't care to download the go compiler, especially with my limited plan. Not that the GUI rename utilities are worthless, but all those little fields confuse me. Working with f2 is much more straightforward.
So far I haven't found a way to put a literal "{" in the replacement string (without running the tool twice) but I rarely (that is never) need this.
@bigpup
Besides completions, it's a single binary. You can put and run it from anywhere (or anywhere in the $PATH for convenience).
---
Edit:
New version - 2.0.2 - fixed a bug (a different one).
Burunduk wrote: Fri Nov 22, 2024 3:38 pm@MochiMoppel
No offense, of course. Just failed to spot an evidence of constructive approach in your initial reaction.
I mentioned the octal workaround approach as a possible option and not as a substitute for a proper fix. The second reason was that literal spaces can always be tricky and using octal or (as I prefer) hex can avoid quotation problems. In complex constructs, where quotations are already used by surrounding expressions, it can be beneficial to use commands that do not need them.
For example the mentioned case does not require quotations when written as f2 -f \\40 -r _
Another option that is not affected by the bug would be f2 -f '[ ]' -r _
So far I haven't found a way to put a literal "{" in the replacement string (without running the tool twice)
I can't see your problem. Example please.
I do see problems when using curly brackets in combination with f2's placeholders, which also use them, but when placeholders come not into play there shouldn't be obstacles. For example f2 -f ^ -r { -f $ -r }
or f2 -f '(.*)' -r '{$1}'
puts curly brackets around the filenames:
Code: Select all
# f2 -f ^ -r { -f $ -r }
*————————————————*——————————————————*————————*
| ORIGINAL | RENAMED | STATUS |
*————————————————*——————————————————*————————*
| Spaced.file 01 | {Spaced.file 01} | ok |
| Spaced.file 02 | {Spaced.file 02} | ok |
| Spaced.file 03 | {Spaced.file 03} | ok |
*————————————————*——————————————————*————————*
The bug has been fixed, the author has noticed it himself without a report.
New version - f2 2.0.3
Fix bug caused by space trimming in `--find`, `--replace`, `--exclude`, and `--exclude-dir`
---
MochiMoppel wrote: Sat Nov 23, 2024 1:34 amI do see problems when using curly brackets in combination with f2's placeholders, which also use them
That's it. It's a good idea to split the replacement string - only one run.
rename file.txt to {f}ile.txt: f2 -f 'f' -r '{f' -f 'f' -r 'f}'
It was a purely theoretical problem but it's solved. Thanks.
By the way, I've found your rename -a
(and -l
). The util-linux in my fossapup was simply outdated.
Burunduk wrote: Sat Nov 23, 2024 11:30 amThe bug has been fixed, the author has noticed it himself without a report.
New version - f2 2.0.3
Good news
By the way, I've found your
rename -a
(and-l
). The util-linux in my fossapup was simply outdated.
The rename tool seems to be a staple application in every Puppy. In BW64 it's version 2.38.1 , not new either but obviously newer than the one you tried. Unfortunately this rename from the util-linux package does not support regex and therefore is almost useless except for very simple string replacements. The identically named rename from the perl package would have regex support, but just like f2 is not part of Puppy and therefore can't be expected to work in scripts published for Puppy users.