News for hackers. Stuff that matters.
Re:Roamer: A Plain-Text File Manager by pmoriarty on Tuesday August 29, 2017 @07:59PM (#15128645)
For things like renaming files, I use a similar utility called "qmv", from renameutils.[1] It is super useful, and one of my most-used commands in the terminal.

For many other file-related operations in my terminal I use Midnight Commander.[2]

I've tried emacs' dired-mode, but I didn't see it being particularly useful compared to Midnight Commander without a ton of time spent on configuring it to work the way I like. I might do that sometime, but until then, Midnight Commander already has so many useful features without any of the time commitment or pain of virtually rewriting much of the same functionality in emacs.

[1] - http://www.nongnu.org/renameutils/

[2] - https://www.midnight-commander.org

Re:Roamer: A Plain-Text File Manager by mikegerwitz on Tuesday August 29, 2017 @10:09PM (#15129202)
A lot of the pain with renaming files can be mitigated using brace expansion in e.g. Bash:

  $ mv path/to/{orig,dest}.foo
  # expands into
  $ mv path/to/orig.foo path/to/dest.foo
Re:Roamer: A Plain-Text File Manager by pmoriarty on Tuesday August 29, 2017 @10:42PM (#15129351)
Your tip is appreciated, but that pales in comparison to what you could do with vim or emacs and a tool like qmv when renaming files.

You could, for instance, rename by regular expressions, easily do block selections and substitutions, use complex macros, etc. The sky is really the limit.

Then there are unlimited undo features of modern editors, and even branching undo histories where you can get back to a state that would be unreachable with linear undos.

Finally, tools like qmv do sanity checking on your renaming plan, so that if you (for example) wind up renaming two files to the same name, it'll warn you and safely let you rename the original files and try again.

As a result of the power and safety these tools provide, I no longer rename directly using my shell's renaming features (like the ones you describe) except for the absolute simplest and foolproof situations. For anything more complex, I use qmv.

Re:Roamer: A Plain-Text File Manager by mikegerwitz on Wednesday August 30, 2017 @08:57AM (#15131681)
I appreciate the clarification. My comfort with shell (which is one of my primary languages for countless tasks) makes it a more viable option for me and blinds me to the issues many people have. That's definitely not the case for many people.

I can certainly recognize the power of what you are describing. Perhaps I'll give it a try in the future.

Out of curiosity: what do you find are your most compelling use cases for the tool(s)?

Re:Roamer: A Plain-Text File Manager by robenkleene on Wednesday August 30, 2017 @05:12PM (#15136082)
Hey Mike, I'm not the original poster, but I'm a good candidate to answer since I'm reasonably comfortable with the shell and I've been looking for a tool like Roamer/qmv specifically because of shortcomings in shell renaming (or my knowledge thereof). My most common case for this is renaming a batch of files to a different naming scheme. For example I was recently renaming 15 or so files that were named like "08/30/2017 John Smith 478939da-b172-4952-b428-d77c4f4f6674.doc" and I wanted them all to be named like "john-smith.doc". I did end up renaming them with the shell but through doing something like `for i in *; do { mv $i \`echo $i | tr '[A-Z]' '[a-z]' | tr ' ' '-'\` } done` (I don't have the final script anymore). Which is slower to write and less elegant than the Roamer/qmv approach. But I'm very curious if there's a better approach to this problem on the shell.
Re:Roamer: A Plain-Text File Manager by kaushalmodi on Thursday August 31, 2017 @07:53AM (#15139643)
Emacs (w)dired can do that in a snap.
Re:Roamer: A Plain-Text File Manager by robenkleene on Thursday August 31, 2017 @07:00PM (#15144710)
Yup, agree 100%! Using `wdired` was my introduction to "editor-based file-system editing". Maintaining an emacs setup for this feature is overkill though.
Re:Roamer: A Plain-Text File Manager by ratbeard on Tuesday August 29, 2017 @10:45PM (#15129367)
zmv is great for when doing mass renaming of files, in zshell. You can for example rename all .jade files to .pug with:

    autoload -U zmv # or put this line in your ~/.zshrc
    zmv -w 'src/**/*.jade' 'src/$1$2.pug'

You can do a dry run by using the `-n` flag too.
Re:Roamer: A Plain-Text File Manager by IronBacon on Wednesday August 30, 2017 @09:55AM (#15132139)
The same thing can be done in a kinda portable way with the pre/post substitution/expansion operators (at the moment don't recall their correct name):

  for a in **/*.jade; do echo mv "$a" "${a%jade}pug"; done
If I'm not wrong it should work in Bash and Ksh too (bar the double * expansion), this when I don't have an Emacs at hand.

In the first invocation I prefer to do a "dry run", if it looks good I proceed removing the echo.

P.S. Your example above should use double quote instead of single quote, otherwise the content is not expanded by Zsh

P.P.S. One recall the pre/post operator looking at the symbols on a US keyboard, the post follows the variable symbol...

Re:Roamer: A Plain-Text File Manager by ratbeard on Wednesday August 30, 2017 @11:09AM (#15132750)
I think the single quotes are correct, and are whats in my history. I think they're arguments to the zmv program, which itself does the expansion and $1 substitutions. Otherwise I think that $1 would be substituted once when you run it instead of for each file.

I've used zmv to also reorganize the directory structure of files too, something that seems easier to do with its glob/variable replace syntax.

Nice to have a cross platform option for usage in scripts though.

Re:Roamer: A Plain-Text File Manager by mbrock on Wednesday August 30, 2017 @03:21AM (#15130265)
One of the things I love about dired-mode is wdired, which lets you edit the contents of the dired buffer as if it were a file, and then hit C-c C-c to make your changes happen: renamings, deletions, even file permission changes.

https://www.gnu.org/software/emacs/manual/html_node/emacs/Wd...

Re:Roamer: A Plain-Text File Manager by ageofwant on Wednesday August 30, 2017 @06:04AM (#15130907)
Used all those and been happy with them, until I found ranger: https://github.com/ranger/ranger
Re:Roamer: A Plain-Text File Manager by kaushalmodi on Thursday August 31, 2017 @07:52AM (#15139639)
I just tried qmv, briefly. I couldn't figure out how to move files to a different directory, and create that directory if it does not exist.

Let's say I do:

    qmv a.txt
And I get this in qmv:

   a.txt                   a.txt
This does not work:

   a.txt                   foo/a.txt
I was expecting qmv to create the foo/ directory if it does not exist. Even if it exists, it does not work.

Do you know if this works? If it does, how do I do it?

Re:Roamer: A Plain-Text File Manager by farresito on Thursday August 31, 2017 @10:27AM (#15140535)
It works for me if the directory exists.
Re:Roamer: A Plain-Text File Manager by kaushalmodi on Thursday August 31, 2017 @12:21PM (#15141383)
Sorry, I was mistaken. I confirm that that works too. I was just comparing with wdired.. wdired (Emacs) creates that foo/ dir if it doesn't exist.
Re:Roamer: A Plain-Text File Manager by icebraining on Wednesday August 30, 2017 @03:20AM (#15130256)
I use Larry Wall's rename, I just wish I could tell it to use "git mv" instead. Seems like qmv allow that with the --command flag, I'll have to try it, thanks!
Re:Roamer: A Plain-Text File Manager by fcoury on Tuesday August 29, 2017 @08:55PM (#15128893)
qmv and qcp looks really useful, never heard of them before!