[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Ranger-users] Bulk-anything command
From: |
Wojciech Siewierski |
Subject: |
Re: [Ranger-users] Bulk-anything command |
Date: |
Thu, 22 Jun 2017 15:51:37 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 |
On 22.06.2017 15:42, John Z. wrote:
>>> 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
signature.asc
Description: OpenPGP digital signature
Re: [Ranger-users] Bulk-anything command, Ingo Lindholm, 2017/06/22
Re: [Ranger-users] Bulk-anything command, John Z., 2017/06/26