Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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)

Update:
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
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

    /J\

      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

        /J\

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

    *.jpe?g

    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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2015-07-05 10:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (61 votes), past polls