-1

I start on shell and i don't know how to compress a folder including just the .jpg and .jpeg files.

Anyone can help me?

Thank you

Sebastien
  • 99
  • 2
  • 1
    Can you please clarify the question? Do you mean to just "include" .jpg files in the archive without compression operations performed on those files, while compressing all other files? – cjc Nov 03 '11 at 12:03

2 Answers2

1
$ tar cvf jpeg.tar $(find /path/to/folder -iregex ".*\.jpe?g")
$ find /path/to/folder -type f -iregex ".*\.jpe?g" | xargs tar cvf jpg.tar
quanta
  • 51,413
  • 19
  • 159
  • 217
  • I would prefer the latter version as the first one might fail in case of many files to compress. This is avoided by the second variant which uses xargs to overcome that problem. (@quanta: a little bit of explanation would be helpful in a case like that). – Sven Nov 03 '11 at 11:31
1

Go to folder

zip archive *.jpg *.jpeg

else, from anywhere

zip archive /path/to/folder/*.jpg /path/to/folder/*.jpeg

archive is the output file.

Ankit
  • 21
  • 5