[mythtv-users] Script quoting problem

Klaus Becker colonius at free.fr
Sat Apr 7 19:40:48 UTC 2018


Le samedi 7 avril 2018, 21:25:49 CEST Russell Gower a écrit :
> —cut--
> 
> > My script (script.sh) is:
> > 
> > ----------------
> > # Cut everything after the point
> > oldname=$(ls *.ts | cut -d. -f1)
> > newname=$(ls *.mpg | cut -d. -f1)
> > 
> > # Rename file
> > for file in *.ts; do
> 
> I think this is your problem
> 
> > 	mv $file $(echo $file | sed 's/$oldname/$newname/g’)
> 
> on the first iteration around the loop you are echoing 1234.ts and piping it
> into sed, the problem is you are asking sed to replace “1234 5678” with
> “film1 film2” as sed doesn’t find a match it returns "1234.ts” again.
> 
> I’m guessing what you are trying to achieve isn’t as straight forward as
> just renaming two files, if you can describe your aim I’ll try and help you
> with the script.
> 
> Regards
>   Russell


Hi Russell,

I use mythlink.pl - https://www.mythtv.org/wiki/Mythlink.pl - which creates 
human readable filenames of recorded episodes in "show_names" directory.

Example:

In my recording directory I have filenames like
11326_20180404132300.ts     11301_20180404181500.ts      

Mythlink.pl creates a subdirectory "show_names" with flienames like
'Fight Club der Tiere.ts'   'Opa wird Papa.ts' which point to the above files.

This is much better than the original filenames created by MythTV in my 
recording directory, but it would be even better if the filenames in the 
recording directory are human readable. I only want the name of the episode, 
nothing else.

So I would like to have in my recording directory 'Fight Club der Tiere.ts'  
and 'Opa wird Papa.ts' instead of 11326_20180404132300.ts and 
11301_20180404181500.ts.

Cheers

Klaus






More information about the mythtv-users mailing list