ExifTool Forum

ExifTool => Newbies => Topic started by: Stephen Marsh on January 16, 2016, 08:07:20 AM

Title: Copy Files to a User Specified Directory
Post by: Stephen Marsh on January 16, 2016, 08:07:20 AM
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).
Title: Re: Copy Files to a User Specified Directory
Post by: Stephen Marsh on January 16, 2016, 08:36:54 AM
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 DIR


exiftool -r -o dummy/ "-directory<PageCount" /Users/stephenmarsh/Desktop/exiftool-test/ -ext .pdf DIR


A small step forward!
Title: Re: Copy Files to a User Specified Directory
Post by: Phil Harvey on January 16, 2016, 10:47:16 AM
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
Title: Re: Copy Files to a User Specified Directory
Post by: Stephen Marsh on January 16, 2016, 05:31:14 PM
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.