Option to define working directory

Started by BogdanH, November 02, 2010, 03:21:27 PM

Previous topic - Next topic

BogdanH

Hi Phil,

Following is related to -stay_open option and my GUI (the way it works right now)... but might be of interest for general usage too.

Assume I need to modify metadata on many image files (but not all of them) in some directory. Now, not actually being in target folder, I can write , i.e.:
exiftool -Author=NN c:\photos\2009\img1.jpg c:\photos\2009\img2.cr2 c:\photos\2009\img7.jpg ...

Does exiftool knows something like:
exiftool -WrkDir=c:\photos\2009 -Author=NN img1.jpg img2.cr2 img7.jpg...
-this?

Having -stay_open in mind, it would be good, if one could specify WrkDir on-the-fly (like this can be done with changing ARG file). Not having that option, for me, -stay_open becomes somehow difficult to implement in GUI -possible, but complicated.

And don't say, this option allready exist :)

Bogdan

Phil Harvey

Hi Bogdan,

No, this feature doesn't already exist. :)

I understand how this could be convenient for you, but I think the implementation could be trickier than it sounds.  What happens if there is both a working directory and a directory specified in the filename?  I suppose the file path should be added to the working directory unless it is an absolute path.  But how do I recognize an absolute path?  The path specifications are different on different systems.  Also, Windows is complicated.  What happens if I specify "wrkdir" for my working directory, and "C:image.jpg" for my file?  Is "C:" an absolute or relative path?  Should the result be "C:\wrkdir\image.jpg" or "C:\image.jpg" or "C:image.jpg"?  And the logic is of course different for different systems. I could perhaps take advantage of the File::Spec module to do some of this work for me, but I try to keep ExifTool as independent of other modules as possible.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

BogdanH

Hi Phil,

You're right. I was looking from my standpoint only (you know, "why complicate, if short way might exist"). At first sight, having such option seems to be of benefit -but it's not that important, though.

Bogdan

Phil Harvey

I see that this is not the first time you have had this problem.

Maybe I would be more sympathetic if I understood the difficulty.  Isn't it as simple as fprintf(outfile, "%s/%s\n", directory, filename) from your software?

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

BogdanH

Hi Phil,

What an amazing memory  :o -I'm baffled (that is the right term, isnt it?).. it's been three years!
I can't recall what "troubles" I had at that time (they must have been solved inbetween), but as it seems, I'm after shortcuts all the time :)

No, you really shouldn't think much about this. I'll try to explain, why I mentioned this:
Inside GUI, ExifTool is executed via Windows standardized API call. This happens each time GUI needs something ExifTool to do. After ExifTool does the job (deliver metadata values or modify tags), process is closed (because ExifTool terminates). It works fine. And when creating ExifTool call, I also define (via API) current working directory. The benefit of this is: when specifying filenames (for ExifTool), there's no need to specify directory -because all files reside in "working" directory (or deeper) anyway. Btw. via API call, I send (pipe) command line as being typed in console.
Having -stay_open, I was thinking to create ExifTool process only when initializing GUI and keep it open until GUI finishes -inbetween, ExifTool would be "ready" all the time. Right now, I can think of two solutions (to make use of stay_open):
1. I don't pass "working" directory at all, when initializing ExifTool (to stay_open). This would require, I need to define path for each image file (so ExifTool know where files are). Well.. paths/filenames can be long and there might be a lot of files.. so, command line could be huge. I think I won't go this way.
2. Everytime user changes directory, I'll close ExifTool process, and create new one, where I'll specify new "working" directory. From this moment on, ExifTool will be in "stay_open" mode (until user changes directory again). User probably won't even notice much what's happening -and will enjoy benefits of "stay_open" while browsing thru files or modifying metadata values -that's the way I'll probably go.

Maybe I'm complicating things in GUI (truth is, my programming knowledge is limited), but in this regard, I don't give up until I find "good enough" solution :) That is, right now, ExifTool is fine as it is.

Sorry for being a bit long with this post,
Bogdan

Phil Harvey

Quote from: BogdanH on November 03, 2010, 03:42:47 PM
1. I don't pass "working" directory at all, when initializing ExifTool (to stay_open). This would require, I need to define path for each image file (so ExifTool know where files are). Well.. paths/filenames can be long and there might be a lot of files.. so, command line could be huge. I think I won't go this way.

There is no need to worry about length of the command line at all.  With -stay_open the arguments are all read from file, not the command line.  :)

Quote
2. Everytime user changes directory, I'll close ExifTool process, and create new one, where I'll specify new "working" directory. From this moment on, ExifTool will be in "stay_open" mode (until user changes directory again). User probably won't even notice much what's happening -and will enjoy benefits of "stay_open" while browsing thru files or modifying metadata values -that's the way I'll probably go.

This is certainly one way to go, and should work fine.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).