[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Ranger-users] Bulk-anything command
From: |
John Z. |
Subject: |
Re: [Ranger-users] Bulk-anything command |
Date: |
Thu, 22 Jun 2017 11:34:02 -0400 |
User-agent: |
Mutt/1.8.3 (2017-05-23) |
> >>> Hi,
> >>> is there a way to execute a command on selected files, much like
> >>> bulkrename does?
> >>> Right now, the only solution that comes to me is faking it, somehow,
> >>> with sh and xargs.
> >>>
> >>> Cheers.
> >> Hi,
> >>
> >> I typically do:
> >>
> >> :shell for f in %s; do <mycommand> "$f"; done
> >>
> >> you could easily bind this to a key with:
> >>
> >> :map X console -p22 shell for f in %%s; do "$f"; done
> >>
> >> then, to run a command, you can type e.g. Xecho<ENTER>
> >>
> >> Regards,
> >> hut
> >
> > Thanks for the tip, I ended doing something similar:
> >
> > :shell echo %s | tr " " "\n" | xargs -L 1 <command>.
> >
> > I figure your way is less roundabout tho, but you know that thing when
> > you're stubborn and just really want to make it work :-D
> >
> >
> May I suggest a change to make it more secure and robust?
>
> :shell printf '%%s\0' %s | xargs -0 -L 1 <command>
>
> It'll handle the spaces in filenames correctly. Technically it'll handle
> even newlines in the filenames but you're unlikely to encounter such files.
>
> Cheers
> --
> vifon
>
Awesome, thanks mate, I didn't even notice -0 option in xargs man :-)
Additionally, I'm glad to have an opportunity to ask a question
regarding %%s: I assume first % escapes the second one? How does this
work, then?
The reason I ask is because just yesterday, I wanted to yank current
directory, and I noticed that when I press 'y', a little menu offers 'd'
which seems to put %d into X selection, using xsel.
However, when I pasted the contents, I got out literal '%s', instead of
directory, so I asssumed %%s was a typo, but now I see it being used.
Can you explain to me, please, what's the thing with it?
--
John
Re: [Ranger-users] Bulk-anything command, Ingo Lindholm, 2017/06/22
Re: [Ranger-users] Bulk-anything command, John Z., 2017/06/26