-1

I've Ubuntu 12.04 VPS, one of the editors has renamed *.png files to *.jpg and inserted into articles.

I'm getting errors in apache2 error.log file.

How can i find wrong typed *.png files in my Ubuntu 12.04 server?

Thanks

John Rock
  • 13
  • 1

2 Answers2

0

Here's one lazy and sloppy but effective way to do it. I suggest you write the "move" commands out to a file and examine them closely after you make a tarball of everything you might destroy.

for img in `find / -type f -iregex ".*\.jp.g" -printx`;
 do newname=$(echo $img | sed s/\.jp.g/\.png/) ;
 echo "I wanna move $img to $newname"; 
done
quadruplebucky
  • 5,041
  • 18
  • 23
0

If you want to find files with a "jpg" extension which are actually PNG files then something like ...

find /usr/share/doc -type f -name '*.jpg' -print0 | xargs -0 file | grep 'PNG image data'

with appropriate substitions of the top level directory and the pattern for file name if you're not using .jpg would give you a list of files one per line followed by file's idea of contents. You could pipe that into your favourite text munging tool to produce just a list of files or even the commands needed to rename/copy the files to the correct names.

Paul Haldane
  • 4,457
  • 1
  • 20
  • 31