ranger-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Ranger-users] Shell script over multiple files


From: G Chandramouli
Subject: Re: [Ranger-users] Shell script over multiple files
Date: Mon, 13 Jun 2016 16:35:04 +0530

When I updated the ranger, ( without changing files inside my .config/ranger directory)  it was still facing the same issue. However when I tried the 2nd suggestion along with the updated version it worked. Couldn't test suggestion-2 on earlier version as I purged the earlier version on my debian system (my bad).
 
Thanks,
Mouli          

On Mon, Jun 13, 2016 at 2:51 PM, hut <address@hidden> wrote:
I think this has something to do with the way macros are expanded in
nested commands.  Try these:

1. switch to ranger from git (or upgrade it), as this sounds like a bug
that has been recently fixed.  Steps:
    1. git clone https://github.com/hut/ranger.git
    2. cd ranger
    3. sudo make install

2. Alternatively, replace %s with %%s

regards,
hut

On Mon, Jun 13, 2016 at 01:40:39AM +0530, G Chandramouli wrote:
> Hello all,
>               I am facing a problem with map chain shell syntax and files
> with white spaces. Does it group two commands with a semicolon ?
>
> I wrote a very small script named testMultiple.sh:
> #!/bin/bash
> echo $1> tmp
> echo $2>> tmp
>
> When I select the two files and run (pressing "X") :
> map X  shell <path to folder>/testMultiple.sh %s
> it gives correct answer to tmp file.
>
> However when I run
> map Y chain shell  <path to folder>/testMultiple.sh %s ; mark_files
> all=True val=False
> it only prints the first two words of first file.
>
>  It probably treats the white space as reason for two different files.
>
> Regards,
> Mouli
>
> On Sun, Jun 12, 2016 at 11:28 PM, G Chandramouli <address@hidden> wrote:
>
> > Hello Jan and Hut,
> > I am not good with python so sorry for that.
> >
> > Following Hut's suggestion, I made a small shell script (sorry for lack of
> > exception handling etc and possibly inefficient  shell scripting) and saved
> > it as "mpvsubs.sh"
> >
> > #!/bin/sh
> > filename1=$1
> > filename2=$2
> > extension1="${filename1##*.}"
> > extension2="${filename2##*.}"
> > if [ "$extension1" == "srt" -o "$extension1" == "sub" ]
> > then
> >         mpv $filename2 --sub-file=$filename1
> >  else
> >         mpv $filename1 --sub-file=$filename2
> >  fi
> >
> > After this I added following line to my rc.conf file
> > map X chain shell /home/gcmouli/mpvsubs.sh %s; mark_files all=True
> > val=False
> >
> > So now I just select the two files with spacebar and press "X" and it
> > starts playing movie with subs.
> >
> >
> > Thanks,
> > Mouli
> >
> > On Sun, Jun 12, 2016 at 10:42 PM, Jan Knížek <address@hidden> wrote:
> >
> >> Hi,
> >> alternatively, you can make a python script (from Arch Linux Wiki):
> >> You can define python command:
> >>
> >> import os
> >> from ranger.core.loader import CommandLoader
> >>
> >> class seemovie(Command):
> >>     def execute(self):
> >>         """ Compress marked files to current directory """
> >>         cwd = self.fm.thisdir
> >>         marked_files = cwd.get_selection()
> >>
> >>
> >> Which will define seemovie command. In cwd.get_selection() you have selected files.
> >> You can than run a shell script or do what you want in python.
> >>
> >> knezi
> >>
> >>
> >> ---------- Původní zpráva ----------
> >> Od: G Chandramouli <address@hidden>
> >> Komu: address@hidden
> >> Datum: 12. 6. 2016 19:09:41
> >> Předmět: Re: [Ranger-users] Shell script over multiple files
> >>
> >> Thanks Hut,
> >>                   Excellent hack. It works !!!
> >>  I was expecting something like "mpvsubs.sh $1 $2" where 1 and 2 will be
> >> filenames selected, whose extensions will be sorted out inside the script
> >> and mpv playing over them from the same script.
> >> Anyways above solution rocks.
> >>
> >> Thanks again,
> >> Mouli
> >>
> >> On Sun, Jun 12, 2016 at 10:22 PM, hut <address@hidden> wrote:
> >>
> >> Hey there,
> >>
> >> Can't think of an elegant way to do it, but you could type `yy` on the
> >> subtitle, then navigating to the movie and running
> >>
> >>     shell mpv %f --sub-file=%c
> >>
> >> This "abuses" the copy buffer as a second file selector.
> >>
> >> You could finish with a `uy` to clear the copy buffer to avoid
> >> accidently copying the subtitle.  The whole command would then be:
> >>
> >>     map X chain shell mpv %f --sub-file=%c; uncut
> >>
> >> Regards,
> >> hut
> >>
> >> On Sun, Jun 12, 2016 at 10:10:04PM +0530, G Chandramouli wrote:
> >> > Hello all,
> >> >               I want to run a shell script over multiple selected files
> >> > (say selected using spacebar ).  How to do this ?
> >> >
> >> > Actually, I am trying to open a movie with mpv and load subtitles. mpv
> >> > player loads subtitles automatically only when subtitles have same
> >> filename
> >> > with srt/sub extension. Renaming subtitles every time is a tiring job. I
> >> > don't want to start a shell prompt and write the command "mpv
> >> filename.mp4
> >> > --sub-file=subfile.srt". Instead I want to select the two files using
> >> > spacebar or something and run a script over them to start mpv and
> >> keeping
> >> > the ranger intact.
> >> >
> >> > Thanks,
> >> > Mouli
> >>
> >>
> >>
> >



reply via email to

[Prev in Thread] Current Thread [Next in Thread]