ImageMagick - Merge files with partial filename matches

these are my filenames in the folder

1710190363_1.jpg
1710190363_2.jpg
1711140603_1.jpg
1711140603_2.jpg
1711140603_3.jpg
1711140603_4.jpg
1711140603_5.jpg

All are .jpg files. File names are dynamic but unique count, first 10 digits then underscore following by a single digit.

Using imagemagick, I m trying to convert all the image files into pdf based on their first ten digits. I want the output as follows

1710190363.pdf
1711140603.pdf

Manually I got this run -

convert 1710190363_1.JPG 1710190363_2.JPG 1710190363.pdf

but dont know how to run in a loop

for %a in (*.jpg) do convert %a o_%a.pdf

Could anyone help me on this script.

ImageMagick - Merge files with partial filename matches, This is a very simple batch-file solution, which assumes that: the numbers behind the _ always start counting at 1 ;; the processing order of the  I'm trying to convert and merge image files based on a partial match of the file name. I've been able to script entire directories and target specific filetypes for conversion/mogrify and merging, but now I'm looking to target those based on matching characters of a filename. My example below might better explain it.

Merge files with partial filename matches [Powershell + ImageMagick], I'm trying to convert and merge images files based on a partial match of the file name. The image conversion is handled by ImageMagick. The command line tool​  ) automagically cause lists of filenames to be generated based on pattern matches. This feature is known as globbing. ImageMagick supports filename globbing for systems, such as Windows, that does not natively support it. For example, suppose you want to convert 1.jpg, 2.jpg, 3.jpg, 4.jpg, and 5.jpg in your current directory to a GIF animation

So you want to group files by the first 10 digits resp. 1st elemtent split by the underscore.

PowerShell

Get-ChildItem *.jpg | 
    Group-Object {$_.Name.Split('_')[0]} |
       ForEach-Object{
           &magick convert $($_.Group -join ' ') $_.Name+".pdf"
       }

ImageMagick, By default the file is written to its original name. However, if the filename extension matches a supported format, the extension is replaced with the image format  File Magic: The image header defines this file as a the special IM text image format (EG a "ImageMagick pixel enumeration" file), this is known in computing circles as the files 'magic' or the code string which identifies this file as being this specific file format.

mogrify(1) — graphicsmagick-imagemagick-compat, montage creates a composite by combining several separate images. In output files, the prefix takes precedence over the filename suffix, and the Use Ellipse to draw a partial ellipse centered at the given point with the x-axis and However, if the filename extension matches a supported format, the  3. Get the coordinates from the filename 4. Composite the tiles onto the blank image It's step 3 that I have a problem with. There just doesn't seem to be a way to extract the coordinates from the filename.

ImageMagick: Command-line Options, By default the file is written to its original name. However, if the filename extension matches a supported format, the extension is replaced with the image format  To find all files anywhere inside /path/to/folder whose names contain bat, you can use: find /path/to/folder -name '*bat*' I have quoted the search pattern *bat* because, if the quotes were omitted and files match *bat* in the current directory, the shell will expand *bat* into a list of them and pass that to find. Then find wouldn't work right.

ImageMagick Image Transforming Utility, –append. append a set of images. This option creates a single image where the If the first character of string is @, the image comment is read from a file titled by Use Ellipse to draw a partial ellipse centered at the given point with the x-​axis However, if the filename extension matches a supported format, the extension  Use the magick program to convert between image formats as well as resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more. See Command Line Processing for advice on how to structure your magick command or see below for example usages of the command.

ImageMagick Image Montage Utility, By default, each image is commented with its file name. To specify a percentage width or height instead, append %. Use Ellipse to draw a partial ellipse centered at the given point, specified width and height, and start and Floodfill changes the matte value of any pixel that matches the color of the target pixel and is a  cd somedirectory change to the desired directory appleArr=(`ls *apple.jpg`) gets all file names that match *apple.jpg applenum is the number of found file names for the appleArr minnum is the smallest number of found files from each of the arrays (the arrays may not all have the same number of files) and if an index is larger than the array

Comments
  • I don't understand your question at all. What's wrong with convert *.jpg result.pdf?
  • If your files are JPEG images, why don't their names end in .jpg?
  • How can your question be tagged both bash and powershell?
  • @MarkSetchell He put Bash, Batch, And powershell as he is open to alternative solutions.
  • thanks, I pasted the lines for f in _1.jpg; do convert "${f%_1.jpg}".jpg "${f%_1.jpg}.pdf"; done but nothing happened, I have given pause at the stop but the command prompt is not stopped
  • First, the naming convention for your files was unclear to me. Do you have a file named 1710190363_1.jpg or just 1710190363_1 or 1710190363_1.JPG? Your exact convention is important. Second, this may be a problem with SO formating but f in _1.jpg .... (as shown in the comment) won't work. It needs to be f in *_1.jpg ..... The * is important. Let me know and then we address the next steps to take.
  • I think OP's filenames end in .JPG (uppercase) despite what he says. Have my vote anyway!
  • I bet the * was actually there, but not in backticks, hence the italics in that comment.
  • yes, I have mentioned * but its not displayed here, its *_1.jpg only