Welcome to Vifm Q&A, where you can ask questions about Vifm usage. Registration is optional, anonymous posts are moderated. GitHub or Google logins are enabled.
0 votes
in vifm by

Hi, I just started using vifm. I have little web access, so my apologies if something like this got asked somewhere.

How do I make this command act on a range?

command! renametochecksum :execute 'rename' system('md5sum %c|cut -d" " -f1').'.%c:e'

Rename accepts a range and one can give it the same number of filenames to rename to. And the man page also says that the range is passed on as %a. But I'm confused, what do I do with that information to make my command with system() work on multiple files? (should I use a for loop on %f in the shell?).

1 Answer

0 votes


You can do something like this:

command! echofiles :execute 'rename' system("md5sum %f | awk '{ ext = $0; sub(\"^.*\\\\.\", \".\", ext); printf \"%%s \", $1 ext }'")

In general for loop in the shell could be a solution. There is nothing to do expansion of multiple macros in lock step, which forces doing the work in the shell.


great, thanks!