7 ms·
Show HN: Massren – multi-rename tool using your text editor
- atmosx 13y agoSmart :-) Since "wget https://raw.github.com/laurent22/massren/master/install/install.osx.sh*" https://raw.github.com/laurent22/massren/master/install/inst... comes out with certification error, because wget doesn't know github's certification, you need to either add an ignore-cert option or you might wanna change that option to 'curl -O https://raw.github.com/laurent22/massren/master/install/install.osx.sh*" https://raw.github.com/laurent22/massren/master/install/inst... which will not came out with an error. Also, curl is installed by default on MacOSX while wget is not :-) Cheers!
- laurent123456 13y agoThanks! I've updated the command lines to use curl instead of wget.
- limmeau 13y agoEmacs users can use wdired in a dired buffer instead. M-x wdired-change-to-wdired-mode (not to spoil the fun of creating a useful command-line tool with Issue9 ;)
- julian37 13y agoYep, and wdired does a few more things as well. From its commentary: - To move files to another directory (by typing their path, absolute or relative, as a part of the new filename). - To change the target of symbolic links. - To change the permission bits of the filenames (in systems with a working unix-alike `dired-chmod-program'). [...] - To mark files for deletion, by deleting their whole filename.
- swah 13y agoSorry, but what is Issue9?
- autofill 13y agoLooks like it's a Go joke/shot: https://code.google.com/p/go/issues/detail?id=9 https://code.google.com/p/go/issues/detail?id=9
- blueblob 13y agoThis is cool. There is already a command called rename[1] that can do some of this but this is much more interactive (and probably more intuitive for vi users). Is this scriptable? [1] http://linux.die.net/man/1/rename http://linux.die.net/man/1/rename
- laurent123456 13y agoThanks, actually I've started developing massren after having tried `rename`, after I realized I had no idea what flavor of regex and syntax I was supposed to be using :) The advantage of using one's own text editor is that it's always familiar. Currently, the command is not really scriptable, but I'd be open to any suggestion.
- blueblob 13y agoI think the syntax is pcrepattern[1] though I may very well be wrong. I definitely agree to the strength being that you know your editor. I suppose scripting would be hard to do without knowing the editor. I artificially applied vim as the editor because that was what you used in the example. I very recently found vimcat[2] from another thread and thought that something similar could be done with this. I guess it may not be much more effective than just using sed and a for loop in <insert shell here> though. [1] http://linux.die.net/man/3/pcrepattern http://linux.die.net/man/3/pcrepattern [2] http://www.vim.org/scripts/script.php?script_id=4325 http://www.vim.org/scripts/script.php?script_id=4325
- bhousel 13y agoholy crap, it has an --undo switch! Why don't more commands have this?
- codereflection 13y agoNice catch!
- bhousel 13y agoYeah I was impressed, I dug into the code a little to see how they accomplish this. They store a sqlite database in ~/.config/massren that contains the rename history and other configuration options. Pretty slick! The app is written in very readable Go.
- e12e 13y agoThat's a nice feature to have. I would say that "undo" really should be something in the filesystem, though. Like with nilfs2: http://www.nilfs.org/en/about_nilfs.html http://www.nilfs.org/en/about_nilfs.html
- captn3m0 13y agoCame here to suggest this as a feature. Was pleasantly surprised.
- aashishkoirala 13y agoNeat! Were you inspired somewhat by Git's interactive rebase or something similar?
- laurent123456 13y agoYes! I think the interface of rebase is great. There are probably other similar "complex" operations that can be simplified by opening a text editor.
- b6fan 13y agoThere is a vim plugin: rename.vim [1] which basically do the same job but without go dependency. [1] http://www.vim.org/scripts/script.php?script_id=1721 http://www.vim.org/scripts/script.php?script_id=1721
- laurent123456 13y agoIndeed it looks like it's doing something very similar, I didn't know about it. I guess one advantage of massren is that it can work with any text editor. The demo is with vim but, for example, on my machine I've set it up to use Sublime Text.
- TomNomNom 13y agoFWIW there is no Go 'dependency' unless you want to build from source. Admittedly if there's no binary available for your platform then you need to build from source.
- p0ckets 13y agoHow is this different from qmv? http://community.linuxmint.com/software/view/renameutils http://community.linuxmint.com/software/view/renameutils
- laurent123456 13y agoI'm not familiar with qmv so I cannot tell but, if it's Linux-only, then one advantage of massren is that it can work on any platform supported by Go (currently tested on Windows, OSX and Ubuntu).
- raimue 13y agoNo, of course renameutils is not specific to Linux Why do you assume that? You can get it from MacPorts or Homebrew for OS X and cygwin for Windows.
- adito 13y agoDoes qmv support undo?
- felixr 13y agoYou should also have a look 'vidir' from Joey Hess' moreutils [1]. I think it is very similar. Moretutils also includes 'vipe' (edit pipe in text editor) and other useful utilities. [1] https://joeyh.name/code/moreutils/ https://joeyh.name/code/moreutils/
- dfc 13y agoMy thoughts exactly. I doubt I go more than two hours without using something from moreutils.
- e12e 13y agoThanks for this. I've been using rename[1] (not actually from [2]) from time to time, but I find it is annoying beyond the simplest of cases (eg: change names to all lowercase). vidir will probably serve me better. [1] A utility that is distributed with perl (on Debian as /usr/bin/prename, with a listing in /etc/alternatives for "rename") [2] http://en.wikipedia.org/wiki/Util-linux http://en.wikipedia.org/wiki/Util-linux
- dewey 13y agoWould be great if someone could add it to homebrew. [0] [0] http://brew.sh/ http://brew.sh/
- msane 13y agoI would also like to be able to brew install this.
- laurent123456 13y agoI've just submitted the homebrew package, let's see if they accept it - https://github.com/Homebrew/homebrew/pull/26819 https://github.com/Homebrew/homebrew/pull/26819
- seivan 13y agoNice work!
- dnr 13y agoIt looks like there are lots of implementations of this idea or there. Here's mine in 30 lines of bash: http://dnr.im/tech/articles/mvdir/ http://dnr.im/tech/articles/mvdir/
- grimgrin 13y agoIt seems like there is a neat thing that could be done with this sort of thing + id3 tags.
- peterjmag 13y agoThis is awesome! Really great work. I can think of about five different instances in the last couple weeks where this could've really helped me out. Oftentimes, I ended up just using something like NameMangler[1] instead and pining for the flexibility of my editor. For the other commenters in this thread that don't see the appeal or keep comparing it to other alternatives, here's what's so compelling to me: - Editor agnostic. This isn't just for vim, people. ST2 is awesome for this kind of thing. - Undo. Easy undo. That's a killer feature, and I wouldn't be surprised if it's unique to this tool. Effusive praise aside, I ran into a couple small issues on OS X: $ massren --config editor 'subl' massren: Config has been changed: "editor" = "subl" $ massren massren: exec: "subl": executable file not found in $PATH subl is indeed in my $PATH, but it's actually just a symlink to the ST2 application directory, as the ST2 docs suggest [2]. I solved this by just adding the app directory to my $PATH, but it'd be nice to keep it out of there if possible. Also, I'd like to be able to pass switches along with my editor command, like git config's core.editor [3]. However, this doesn't seem to work: massren: exec: "subl -wn": executable file not found in $PATH Anyway, great work once again, and thanks for releasing such a cool tool! [1] http://manytricks.com/namemangler/ http://manytricks.com/namemangler/ [2] http://www.sublimetext.com/docs/2/osx_command_line.html http://www.sublimetext.com/docs/2/osx_command_line.html [3] https://help.github.com/articles/using-sublime-text-2-as-your-default-editor https://help.github.com/articles/using-sublime-text-2-as-you...
- laurent123456 13y agoThanks for the feedback! I would have expected Go to find the subl executable if it's in the PATH, even if it's a symlink but apparently not. I will check if this can be improved. At the moment, the tool indeed doesn't support parameters for the text editor, though it's quite trivial to implement. I'm going to add this soon.
- JadeNB 13y agoAt a quick thought, is there any chance that 'subl' is actually an OS X alias (https://en.wikipedia.org/wiki/Alias_%28Mac_OS%29 https://en.wikipedia.org/wiki/Alias_%28Mac_OS%29) (which can't easily be followed from the command line), rather than a symlink?
- seivan 13y agoHmm should I look into getting this on homebrew? Would anyone other than me be interested?
- jweir 13y agoGreat tool. This wasn't clear from the README, but this will work with files across directories (which is both useful and confusing) massren /*foo.rb Will rename matching files in different directories, but there is no indication of what directories those are in the editor. <snark>Also, how could you build something so useful without generics!?</snark>
- xbryanx 13y agoNameChanger is another great tool that helps with this family of tasks on OS X. http://www.mrrsoftware.com/MRRSoftware/NameChanger.html http://www.mrrsoftware.com/MRRSoftware/NameChanger.html
- seniorsassycat 13y agoI wrote a hack that uses sed to rename files and I've been pretty happy with it despite its simplicity. https://github.com/everett1992/utils/blob/master/sed-utils/mv-sed https://github.com/everett1992/utils/blob/master/sed-utils/m...
- spc476 13y agoYou might also consider checking for the environment variable $EDITOR. It's defined by POSIX and there are existing tools that use it.
- rsync 13y agoI have been using the tool 'vimv' for years now ... how is this different/worse/better ? Perhaps the ability to define any editor ?
- mcovey 13y agoOne program I missed when I moved from Windows to Linux was Freename - http://freename.sourceforge.net/ http://freename.sourceforge.net/ - which does exactly this. My solution was a bit hackier, a bash script that did spit out a bunch of lines for each file in a directory, each with "(mv|cp) 'foo.bar' ''", ready for me to edit and then paste back into a terminal window.