Page 1 of 1

Appending multiple images from a folder confusion

Posted: 2016-09-19T14:38:06-07:00
by expiredyogurt
I'm looking to append a bunch of comic I downloaded into one long strip and found that -append is better than compiling it to pdf as there were white lines between the images.

I'm currently using a Mac el cap, specifically automator to automate this for me as there are 200 chapters for the manga I want to append.

I am trying to make a work flow with automator so when I drag and drop the folder on to the work flow, it would append all the images and output the file into the same folder that I originally drag and drop into.
i.e. drop chapter 1 onto the work flow and the appended output should be in the chapter 1 folder.

This is what my code in automate looks like:

Code: Select all

for f in "$@"
do
	cd "$@"
	/usr/local/bin/convert "$@" -append Chapter%03d.jpg
done
The error/confusion I'm getting is, I'm not able to output the file into the same folder as the original images but it's outputting at my $home folder? I tried to set a path to desktop but when it comes to processing the other chapters, it overwrites the output file. I tried to set a variable on the output filename to be sequential but I'm not good enough to make it so.

Is there a way I can fix it and still use automator to automate the work flow or do I have to manually do all 200 chapters? Thanks in advance for the helps.

Re: Appending multiple images from a folder confusion

Posted: 2016-09-19T15:03:13-07:00
by fmw42
You are doing a loop on f but not using that variable $f anywhere! What is an example of f from $@? Should you not be cd to the directory you want, then collect all images into a list and then append. Perhaps I misunderstand. Are you trying to append all images in a directory for one Chapter or are you trying to create all chapters at one time. If the latter, you likely will need to make a list of each directory, then loop over those directories, do cd to one directory, then collect all the images from that directory as a variable and put that into a give convert with a filename that indicates the output name corresponding to that directory.

In the following I have assumed your comics are pdf. If not, set the ls command to find * (everything) or just some filetype as I did with whatever the filetype(s) is/are. Use absolute paths.

Code: Select all

i=1
dir_list="path2dir1 path2dir2 ... path2dirN"
for path in $dir_list; do
cd $path
file_list=$(ls *.pdf)
ii=$(printf "%03d\n", $i)
convert $file_list -append Chapter$ii.jpg
i=$((i+1))
done
The above is untested.