Glob for multiple file extensions

I’m working on a script that I’m using to rename files from my various digital cameras.  I typically use three cameras when travelling – a DSLR or MILC body, a compact, and my phone.  I want to rename the files with the date the timestamp, prepended to the file name.

I need to find the correct files, and rather than just taking a chance on all files found in a directory, I’d like it to search for specific files. Here are a list of the formats I have:

2015-01-31 08.12.41.mov
00014.MTS
P1000756.MP4
IMG_2102.MOV
C0014.MP4

So to get a list of these files in the current directory, I have the following:

ls -A [C,P]*.MP4 [1-9]*.MTS IMG*.MOV

This gives me a simple list of files that I can feed into the a for loop to read the timestamps and rename the files.

If you noticed that the glob doesn’t include anything to match .mov (lower case) files, this is intended. The only camera I own that produces lowercase .mov files already use a timestamp as the file name.

There are more elegant ways, if you don’t have specific file name conventions that go with specific extensions. Here’s an example:

ls -A [1-9,C,P,I]*.{MOV,MTS,MP4}

Hope this helps someone!

First post!

For the past decade or so, I’ve maintained about a dozen different blogs.  No, that sounds wrong.  Failed to maintain.  Yes, I failed to maintain about a dozen different blogs.  These were differentiated by their specific topic or sub-topic, and who they were aimed at.

Some were out out the public internet, some were internal only at my work and would require some redactions.  At least one was meant to be public, but I restricted it to my home IP early on and never removed that restriction.

Well, I think it’s to do something about this.  Over the next year or so, I’m going to consolidate everything into this blog.  Some articles require a fair deal of clean up, others need to have identifying information removed.  There’s  lot that’s now technically obsolete.  I mean, who’s debugging obscure dovecot mbox parsing bugs introduced – and subsequently fixed -by a RHEL4 update?  Well, on one of my blogs, the article dealing with this is still the most popular.  So, for posterity I will port these articles too, and do my best to backdate them appropriately.