I am scanning a directory for PDF files and then copying the files to a new directory named after the PDF page count.
I have made it this far from searching the forums and reading the manual (Mac OS):
exiftool -r -o dummy/ "-directory<PageCount" /Users/stephenmarsh/Desktop/exiftool-test/*.pdf
This is working and for a CLI shy user I am really happy to have made it this far, however I would like to refine the results:
1) Where/how can I insert a command to create the directories and copy the files to a specific target directory? Lets say that I wanted the results of the previous command to go to /Users/stephenmarsh/Desktop/my-output-here/ I ask because by default the results are being written to /Users/stephenmarsh/
2) The new directories are simply named after the page count (as requested) such as the following for an 8 page PDF:
8
However what if I would like to add a prefix or suffix, such as _Temp:
8_Temp
Thank you in advance.
EDIT: With further testing I appear to be having problems with the -r command, as subfolders are not being created, this only works at the top level of the directory (my initial tests did not contain sub-directories in the main directory).
I wrote:
Quote"EDIT: With further testing I appear to be having problems with the -r command, as subfolders are not being created, this only works at the top level of the directory (my initial tests did not contain sub-directories in the main directory)."
It appears that I should not use the
*.pdf when using
-r The revised command line below works for the sub-directories, removing
*.pdf and adding
-ext .pdf DIRexiftool -r -o dummy/ "-directory<PageCount" /Users/stephenmarsh/Desktop/exiftool-test/ -ext .pdf DIR
A small step forward!
Hi Stephen,
Let me try to answer your questions:
You can copy the files to any directory you want with an argument something like this:
'-directory</Users/stephenmarsh/something/${pagecount}_temp/anotherLevel'
See the -tagsFromFile option in the application documentation (https://exiftool.org/exiftool_pod.html) for more information.
- Phil
Thanks Phil! With a little bit of experimentation, I finally achieved the following through half an hour of trial and error:
Suffix of _Temp
exiftool -r -o dummy/ '-directory</Users/stephenmarsh/Desktop/exiftool-test-output/${pagecount}_temp' /Users/stephenmarsh/Desktop/exiftool-test/ -ext .pdf
Prefix of Temp_
exiftool -r -o dummy/ '-directory</Users/stephenmarsh/Desktop/exiftool-test-output/temp_${pagecount}' /Users/stephenmarsh/Desktop/exiftool-test/ -ext .pdf
So I am happy with the CLI approach...
Now I will see if I can make this work using Apple Automator as a service on selected files in the Finder.