You can't include someone else's directory. Read_dir() is only for use on the local system.
You'd have to get a list of all the files and weed out what's JPEG and what's not. Also, as someone said earlier, you'd probably have to kill the script several times. PHP, as a default, can only use 8MB of memory per script, and 150,000 JPEGs might take all of that up. Also, it will time out at the default of 30 seconds, which will probably come before 8MB of RAM.