Page 1 of 1

Rename image conversion to parent folder name

Posted: 2018-10-16T03:41:51-07:00
by keljnr
I have a simple script to convert all jpegs in a folder into one pdf:

Code: Select all

magick *jpg* myfile.pdf
Is it possible to rename the myfile.pdf to the folder name it sits in? So if the jpgs are in a folder called 'myFolder', the pdf will be myFolder.pdf

I have a lot of folders with images and don't want to manually retype the pdf filename.

Many thanks.

Re: Rename image conversion to parent folder name

Posted: 2018-10-16T08:00:47-07:00
by snibgo
You would need to decide on the rules when in a nested folder, eg /mydir/mydir2/abc.pdf. What do you want the new name to be?

You might do this by setting a shell variable before the magick command, or renaming afterwards.