Live data from Hacker News

New(ish) command line tools

jvns.ca

151–160 of 252 posts

Re: New(ish) command line tools

#151

I really like the approach of pipe-rename ( https://github.com/marcusbuffett/pipe-rename ) for renaming many files. It's especially convenient for people who can efficiently edit many lines in their favorite text editor (so everybody here, I guess). Main problem: you maybe don't do this kind of operation frequently enough to remember how it's called or how you aliased it.

My approach is something like

  $ ls / find # tweak until I have a list of things to rename
  $ for file in $(ls / find...); do echo "mv $file $(echo $file | sed ... )"; done # this prints mv commands for renaming, I can inspect them as needed
  $ for file in $(); do...; done | sh # execute the renaming
It is inspectable, easy to cancel (just don't pipe to shell), incremental... just needs wrangling with bash etc. which is a bit of a pain.

It works for a bunch of other all-or-nothing commands, which are potentially quite destructive; use a for-loop to generate the commands, tweak until you're happy with it, then pipe to shell.

Re: New(ish) command line tools

#152

I really like the approach of pipe-rename ( https://github.com/marcusbuffett/pipe-rename ) for renaming many files. It's especially convenient for people who can efficiently edit many lines in their favorite text editor (so everybody here, I guess). Main problem: you maybe don't do this kind of operation frequently enough to remember how it's called or how you aliased it.

It is a good approach. Emacs has dired and other modes for doing this.

To expand on this: if you look at a dir in Emacs then change the buffer to be writable, you can change file names and saving the buffer renames files. You can also edit the permissions columns in a similar way. And there is vc integration so eg eMacs will hg mv files in a mercurial repo.

Re: New(ish) command line tools

#153

I really like the approach of pipe-rename ( https://github.com/marcusbuffett/pipe-rename ) for renaming many files. It's especially convenient for people who can efficiently edit many lines in their favorite text editor (so everybody here, I guess). Main problem: you maybe don't do this kind of operation frequently enough to remember how it's called or how you aliased it.

The demo requires a sufficiently smart editor. But with a sufficiently smart editor you can prepare a script and pipe it into an interpreter.

Re: New(ish) command line tools

#155

I really like the approach of pipe-rename ( https://github.com/marcusbuffett/pipe-rename ) for renaming many files. It's especially convenient for people who can efficiently edit many lines in their favorite text editor (so everybody here, I guess). Main problem: you maybe don't do this kind of operation frequently enough to remember how it's called or how you aliased it.

The demo requires a sufficiently smart editor. But with a sufficiently smart editor you can prepare a script and pipe it into an interpreter.

Pipe rename automates the following common script in a much nicer way:

  !ls
  qaVypImv “escapeA” escapeJi”escapeA”escapejq99@a

Re: New(ish) command line tools

#156

I really like the approach of pipe-rename ( https://github.com/marcusbuffett/pipe-rename ) for renaming many files. It's especially convenient for people who can efficiently edit many lines in their favorite text editor (so everybody here, I guess). Main problem: you maybe don't do this kind of operation frequently enough to remember how it's called or how you aliased it.

I like that idea of converting metadata to text, so you can do text operations on it that you are already familiar with, and then apply the changes back.

If your problem can be solved by just regexps, there's a "rename" tool installed by Perl I've used for decades. E.g.

    rename -n 's/JPEG$/jpg/' *JPEG
Will apply the substitution for JPEG at end of the filename to just jpg. The -n will run without renaming so you can see what it intends to do.

Re: New(ish) command line tools

#157
post #156

I really like the approach of pipe-rename ( https://github.com/marcusbuffett/pipe-rename ) for renaming many files. It's especially convenient for people who can efficiently edit many lines in their favorite text editor (so everybody here, I guess). Main problem: you maybe don't do this kind of operation frequently enough to remember how it's called or how you aliased it.

I like that idea of converting metadata to text, so you can do text operations on it that you are already familiar with, and then apply the changes back. If your problem can be solved by just regexps, there's a "rename" tool installed by Perl I've used for decades. E.g. rename -n 's/JPEG$/jpg/' *JPEG Will apply the substitution for JPEG at end of the filename to just jpg. The -n will run without renaming so you can s…

A newer tool 'brename' is similar but uses standard inputs and allows for full regex. Like rename it has dry mode for safe renaming.

Re: New(ish) command line tools

#158
related topics that may be interesting:

Ask HN: Best Command-Line Applications? https://news.ycombinator.com/item?id=18483460

Command line tools for productive programmers https://news.ycombinator.com/item?id=27992073

An Illustrated Guide to Useful Command Line Tools https://news.ycombinator.com/item?id=21363121

Re: New(ish) command line tools

#159

Earlier quoted context omitted.

It is a good approach. Emacs has dired and other modes for doing this.

To expand on this: if you look at a dir in Emacs then change the buffer to be writable, you can change file names and saving the buffer renames files. You can also edit the permissions columns in a similar way. And there is vc integration so eg eMacs will hg mv files in a mercurial repo.

I didn't know about the VC integration. After 15 years emacs can still surprise me!

Re: New(ish) command line tools

#160
post #4

As a maintainer, I hoped to see Hurl [1], a tool for testing HTTP with plain text and curl, but alas it isn’t here! [1] https://hurl.dev

Oh it runs stuff like curl. I use html2text just about 5 times a day, and want better ways of working with html _as_ text without a browser of an kind.
Post reply on HN