Hi
I used cd ~/Pictures; find . -type f | egrep "*.jpg" | parallel mogrify -resize 50% {}
command with great success in the past, but today it does not work. There are two things different now, and one is the pictures are in ~/Pictures/updated_pics and the other is a message I got about GNU parallel. I ran parallel --citation
and said “will cite” or something close. The reason was to silence the message, but I do not know what I am doing wrong. Can you help please? I run the command, but the sare the same size
Are you on Fedora 36?
I don’t have any issues with your command, it runs as expected.
By the way, you can skip the “cd” part, unless the command is part of a script and you need to find yourself in the top level directory, e.g.
find ~/Pictures -type f | egrep "*.jpg" | parallel mogrify -resize 50% {}
Is there any chance that the jpeg files you want to resize have a different extension, such as .jpeg or .JPG?
You can catch the jpeg files with “*.jp*g” and uppercase files with the -i flag passed to egrep:
egrep -i "*.jp*g"
Hi Alex,
Thank you so much for the reply. I was able to make the changes. I am on version 36. I just removed the parallel keyword and used mogrify command. I think for the number of files I have, that is ok.
If you run the command with “parallel” in place, do you get any errors?
Good Morning,
No, it just does not seem to have an impact. Here is what I see before I run the command:
$ ls -al
total 15376
drwxr-xr-x. 1 692 Sep 21 17:26 .
drwxr-xr-x. 1 1476 Sep 21 09:40 ..
drwxr-xr-x. 1 310 Sep 21 17:40 new
-rw-r--r--. 1 566712 Sep 21 12:33 P9210004.JPG
And here is the command:
cd ~/Pictures/updated_pics; find . -type f | egrep “*.jpg” | parallel mogrify -resize 50% {}
And here is the result:
ls -al
total 15376
drwxr-xr-x. 1 692 Sep 21 17:26 .
drwxr-xr-x. 1 1476 Sep 21 09:40 ..
drwxr-xr-x. 1 310 Sep 21 17:40 new
-rw-r--r--. 1 566712 Sep 21 12:33 P9210004.JPG
I alson tried the command without the cd.
Well, if there’s only one image file there is no point in running the job in parallel. Depending on their size and number and the specs of the host, you might start to see a significant difference when there are tens or hundreds of files.
As a side note, the reason why the command as you ran it does nothing is that grep runs a case-sensitive search (no -i
flag) and the file extension is uppercase. If you want to be on the safe side, you can check which files will get treated by issuing the command up to the end of the first pipe, i.e. find . -type f | egrep “*.jpg”
. In this particular case, that would return an empty string, as nothing matches “*.jpg”.
Yes, thank you so much. It was the filenames and the case of the file names. I assumed there was some issue with parallel since I saw the notice about citation when I first ran the command. Then silencing it actually worked. But I ran into the other issue, and automatically assumed that I am still being held back due to something having to do with parallel. Thank you so much. On a different note, I have about 20 files, but I only pasted one as an example. I realized the number is still too small to see a difference in using parallel. These tools and the linux command line are just so great for these types of activities.