Hopefully somebody can point out my error with a script.
This is it =================== #! /bin/bash # Script to extract thumbnails from .ts files for use on a Humax machine
set -e # set -x # shopt -s nocasematch
for FILE in *.ts do bname=$(basename "$FILE") dir=$(dirname "$FILE") # extension="${bname##*.}" filenamewoext="${bname%.*}" imagefile="${dir}/""${filenamewoext}.png" ffmpeg -i "$FILE" -vframes 1 -ss 00:01:00 -f image2 "$imagefile" done =================== My problem is that I can sometimes have .ts files and others .TS files so how do I persuade bash to search for both case types?
As you can see, I've tried setting 'nocasematch' but it's commented out as that doesn't seem to work for me. Searching online produced the 'tr' command but how do I apply that, if indeed it is the correct solution?
Any help appreciated.
On Sat, 14 Nov 2015 11:35:09 +0000 Chris Green cl@isbd.net wrote:
Surely it's easy, just do:-
for FILE in *.ts *.TS
Indeed. It's that's simple!
Many thanks. All my searching didn't produce that solution.
On 14 Nov 2015, at 11:30, Chris Walker alug_cdw@the-walker-household.co.uk wrote:
As you can see, I've tried setting 'nocasematch' but it's commented out as that doesn't seem to work for me. Searching online produced the 'tr' command but how do I apply that, if indeed it is the correct solution?
Chris's solution is a fine one, but just for completeness:
nocasematch is for `case` and `[[`. For your purposes you'd want nocaseglob. For example:
$ shopt -s nocaseglob $ shopt nocaseglob nocaseglob on $ ls *ts 1.ts 2.TS
The `tr` command is for changing characters, for example:
$ ls | tr 'TS' 'ts' 1.ts 2.ts
That's not ideal here, because you want the case insensitivity to apply to the matching, not the output.
You could also use some other command to select the files. For example:
$ for file in $(find . -iname '*.ts' -maxdepth 1); do echo $file ; done ./1.ts ./2.TS
-- Martijn
On 14 Nov 2015, at 11:30, Chris Walker alug_cdw@the-walker-household.co.uk wrote:
As you can see, I've tried setting 'nocasematch' but it's commented out as that doesn't seem to work for me. Searching online produced the 'tr' command but how do I apply that, if indeed it is the correct solution?
Chris's solution is a fine one, but just for completeness:
nocasematch is for `case` and `[[`. For your purposes you'd want nocaseglob. For example:
$ shopt -s nocaseglob $ shopt nocaseglob nocaseglob on $ ls *ts 1.ts 2.TS
The `tr` command is for changing characters, for example:
$ ls | tr 'TS' 'ts' 1.ts 2.ts
That's not ideal here, because you want the case insensitivity to apply to the matching, not the output.
You could also use some other command to select the files. For example:
$ for file in $(find . -iname '*.ts' -maxdepth 1); do echo $file ; done ./1.ts ./2.TS
-- Martijn
On Sun, 15 Nov 2015 17:04:21 +0000 Martijn Koster mak-alug@greenhills.co.uk wrote:
On 14 Nov 2015, at 11:30, Chris Walker alug_cdw@the-walker-household.co.uk wrote:
As you can see, I've tried setting 'nocasematch' but it's commented out as that doesn't seem to work for me. Searching online produced the 'tr' command but how do I apply that, if indeed it is the correct solution?
Chris's solution is a fine one, but just for completeness:
nocasematch is for `case` and `[[`. For your purposes you'd want nocaseglob. For example:
$ shopt -s nocaseglob $ shopt nocaseglob nocaseglob on $ ls *ts 1.ts 2.TS
The `tr` command is for changing characters, for example:
$ ls | tr 'TS' 'ts' 1.ts 2.ts
That's not ideal here, because you want the case insensitivity to apply to the matching, not the output.
You could also use some other command to select the files. For example:
$ for file in $(find . -iname '*.ts' -maxdepth 1); do echo $file ; done ./1.ts ./2.TS
Thanks Martijn. I'll file this away for future reference.