3 ms·
given that this is only 100 lines of code i am quite impressed. however, i miss one feature for which i'd use a filemanager: in-place file renaming. in most ca
by em-bee 8y ago
given that this is only 100 lines of code i am quite impressed.
however, i miss one feature for which i'd use a filemanager: in-place file renaming. in most cases when i want to rename a file, i want to change a small part of it, and i don't want to have to retype the whole filename.
i have yet to find a commandline utility (emacs doesn't count ;-) that offers that.
- heavenlyblue 8y agoPut the filename into a shell variable, then sed or split it into characters and then concat.
- em-bee 8y agolooks like ranger does it. i'll have a closer look at that
- Lio 8y agoNo need for a filemanager for in place file renaming. For that I'd just use curly bracket in bash or zsh. e.g. mv /path/to/file{-old-name,-new-name}.txt which expands to: mv /path/to/file-old-name.txt /path/to/file-new-name.txt So use tab completion to get your path then go back and stick your curly brackets into it as needed. Oh and it works for things like git branch renaming or anything else you do in the terminal.
- JNRowe 8y agoIf you're a zsh user you can also use the other zshparam(1) stuff too. Like "mv file.ext{,(:r)}" to perform "mv file.ext file", or :l to lowercase a filename, or any number of other sometimes useful or often pointless things ;) I've used :l a number of times, but :s for substition is probably the most useful in general.
- em-bee 8y agothanks, but that takes more conscious effort to get right that is worth it for me. i tend to just copy the filename twice and then edit the second version to the target. but now i'll become good friends with qmv greetings, eMBee.
- JNRowe 8y agoIf I'm understanding you correctly, then imv[1] is a great tool for this. 'imv $filename' pops you in to a readline enabled prompt to edit $filename. Given that it is readline you can even add extra options in your ~/.inputrc to add additional features to it, I have mappings for custom dir prefixes as an example. It also comes with qmv, which will pop open an editor for you to perform inplace edits on filenames. Which is kinda like dired as an emacs comparison, at least if you squint an awful lot. 1. http://www.nongnu.org/renameutils/ http://www.nongnu.org/renameutils/
- em-bee 8y agothose are exactly like what i had in mind. thanks! qmv even handles swapping filenames which ranger doesn't. greetings, eMBee.
- peff 8y agoPerl has shipped with a `rename` utility for ages, that you can use like: rename 's/foo/bar/' *.ext Of course you have to know Perl...
- Beldin 8y agoTab is your friend! At least in zsh it manages file name completion well - including cycling through options of there is more than 1 match for your partial name. Of course, you could get more advanced with parameter tricks, eg. ${i%.ps}.pdf for changing the extension of $i from ps to pdf. (Technically: truncating the ending iff it matches ".ps" and adding ".pdf" no matter what.)