sylikc / pyexiftool

PyExifTool (active PyPI project) - A Python library to communicate with an instance of Phil Harvey's ExifTool command-line application. Runs one process with special -stay_open flag, and pipes data to/from. Much more efficient than running a subprocess for each command!
Other
144 stars 17 forks source link

Report progress during batch processing #83

Open mundodisco8 opened 3 months ago

mundodisco8 commented 3 months ago

Hi,

I've been playing with the module and so far it's proven to be really useful, thanks for your work.

I'm renaming some files based on their date of creation. Sometimes, I have to process folders with a couple thousand files. I used to do a "for file in files: process(file)" but that took hours, and found that ExifTool is capable of doing batch processing itself, WAY FASTER (minutes), so I use the execute_json to do the batch processing for me.

Nevertheless, it still takes minutes, and was wondering if there's a way to report progress during processing, or at least an "spinner".

sylikc commented 1 week ago

So, currently PyExifTool doesn't support any type of progress. I could envision doing something like a callback to dump out the os.read() somewhere... but I'm not necessarily sure this would be helpful to the caller.

https://github.com/sylikc/pyexiftool/blob/e54f96cd75758096f72bc97c42390f1f9fef8010/exiftool/exiftool.py#L125-L135

The issue is that the os.read() is given raw bytes back. These are neither decoded, nor does pyexiftool know exactly how much data is supposed to be returned.

If we could come up with something that might be useful, it could be implemented. As it stands, it's a bit difficult to find a good implementation that has a general use case