Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Find all JPEG files in a directory

by Transient (Hermit)
on Aug 11, 2005 at 20:26 UTC ( #483118=note: print w/ replies, xml ) Need Help??

in reply to Find all JPEG files in a directory

with Perl you can use File::Find. But you should be able to do this from the command line (or script):

find /path_to_start_from -name *.jpe?g 2>/dev/null > output.txt
find /path_to_start_from -name "*.jp{,e}g" 2>/dev/null > output.txt
(I didn't check the command itself, but that should be close)

Updated shell command (to what should work on Linux - untested because I'm on AIX)

Comment on Re: Find all JPEG files in a directory
Select or Download Code
Replies are listed 'Best First'.
Re^2: Find all JPEG files in a directory
by gellyfish (Monsignor) on Aug 11, 2005 at 20:39 UTC

    I don't know about your find command but mine doesn't do that - I think you'll need to use grep:

    find ../images | egrep '\.jpe?g$'
    alternatively if just one directory level is required then you could ls - with bash you can do:
    shopt -s extglob; ls ../images/*.jp?(e)g; shopt -u extglob


      You're right on that one... this is supposed to be supported, but I can't get it to work on AIX:
      find . -name "*.jp{,e}g"

        I think you might need to use single quotes around the argument to -name lest it get expanded by the shell before it gets passed to find


Re^2: Find all JPEG files in a directory
by Bob9000 (Scribe) on Aug 11, 2005 at 20:45 UTC


    The shell might have something to say about that...

    (Actually, Bourne-style shells will still pass it through in the likely event that nothing matches that glob, but it's not very safe.)

    edit: And the only way to get the match you want from find is to use something like:

    find dir -name \*.jpg -or -name \*.jpeg

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://483118]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2015-10-09 05:39 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (233 votes), past polls