Parallelize a generic exiftool command

Started by lombardata, February 27, 2023, 07:51:45 AM

Previous topic - Next topic

lombardata

Hi everyone,
I would like to parallelize a series of exiftool commands and found this old topic :
https://exiftool.org/forum/index.php?topic=7692.15
First of all I would like to know if there is another way to parallelize exiftool commands on multiple cores (e.g. geotag commands) or if we have to dive into Perls scripts.
If the answer is the second option, I tried to adapt Hayo's script to my needs and changed the first part with  :
# The list of directories with all the images
my @imagedir_roots = ("/path/frames");
# Number of parallel processes
my $parallel = 16;
my $exiftool_command = "exiftool -m '-SubSecDateTimeOriginal= '2023:10:20 09:49:05.600000'' /path/frames -fileorder filename -overwrite_original"
but get the following error :
Quotesyntax error at exiftool_workflow.pl line 22, near "my "
Global symbol "@atfiles" requires explicit package name (did you forget to declare "my @atfiles"?) at exiftool_workflow.pl line 22.
Global symbol "@atfiles" requires explicit package name (did you forget to declare "my @atfiles"?) at exiftool_workflow.pl line 26.
Global symbol "@atfiles" requires explicit package name (did you forget to declare "my @atfiles"?) at exiftool_workflow.pl line 32.
Global symbol "@atfiles" requires explicit package name (did you forget to declare "my @atfiles"?) at exiftool_workflow.pl line 37.
Execution of exiftool_workflow.pl aborted due to compilation errors.
I'm not used in working with Perls scripts, so I was wondering if someone knew how to adapt Hayo's script to a generic exiftool command.
Thank you in advance and have a good week !

StarGeek

Your quotes are wrong.  Running it through Perl by setting the variable and then printing the variable
C:\>perl -e "my $exiftool_command = \"exiftool -m '-SubSecDateTimeOriginal= '2023:10:20 09:49:05.600000'' /path/frames -fileorder filename -overwrite_original\"; print $exiftool_command
exiftool -m '-SubSecDateTimeOriginal= '2023:10:20 09:49:05.600000'' /path/frames -fileorder filename -overwrite_original

You can see that the single quotes around the SubSecDateTimeOriginal assignment are doubled.  You should either use quotes around the whole thing
'-SubSecDateTimeOriginal=2023:10:20 09:49:05.600000'
or the part with the space
-SubSecDateTimeOriginal='2023:10:20 09:49:05.600000'

I'm assuming that you're using Mac/Linux.  If on Windows, you probably have to swap the quotes, as I don't think any Perl execute commands would call PowerShell.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

lombardata

Thank you StarGeek for your reply.
I tried both options, but the error still remains:
syntax error at exiftool_workflow.pl line 22, near "my "
Global symbol "@atfiles" requires explicit package name (did you forget to declare "my @atfiles"?) at exiftool_workflow.pl line 22.
Global symbol "@atfiles" requires explicit package name (did you forget to declare "my @atfiles"?) at exiftool_workflow.pl line 26.
Global symbol "@atfiles" requires explicit package name (did you forget to declare "my @atfiles"?) at exiftool_workflow.pl line 32.
Global symbol "@atfiles" requires explicit package name (did you forget to declare "my @atfiles"?) at exiftool_workflow.pl line 37.
Execution of exiftool_workflow.pl aborted due to compilation errors.
where line 22 is :
my @atfiles;I'm on Linux;)
Have a good day

Phil Harvey

You can run applications in parallel easily.  All you have to do is launch another "exiftool" while the other one in still running.  There is no need to get into writing Perl scripts.  Just be sure each instance is operating on a separate set of files.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

Quote from: lombardata on February 28, 2023, 03:17:15 AMwhere line 22 is :
my @atfiles;

What are the lines before that?  The error is most likely occurring before line 22.

Ah, did you forget the semicolon at the end of the previous line of code?  Your first post is missing that.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

lombardata

Quote from: StarGeek on February 28, 2023, 10:00:35 AM
Quote from: lombardata on February 28, 2023, 03:17:15 AMwhere line 22 is :
my @atfiles;

What are the lines before that?  The error is most likely occurring before line 22.

Ah, did you forget the semicolon at the end of the previous line of code?  Your first post is missing that.
Thank you vey much, my fault !
now it works:)