Skip to content

Commit 57928cc

Browse files
committed
Add ExifTool.RunArgs method to run ExifTool without specifying a file.
1 parent cfb156a commit 57928cc

6 files changed

Lines changed: 22 additions & 1 deletion

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,12 @@ exifToolStdOut = exifTool.Run("C:/someFile.png", ["-PNG:Copyright=Some copyright
306306
WScript.Echo(exifToolStdOut) // contains: "1 image files updated"
307307
```
308308

309+
Run ExifTool without specifying a file name.
310+
```javascript
311+
var res = exifTool.RunArgs(["-list"])
312+
WScript.Echo(res) // prints the list of available tags
313+
```
314+
309315
## UCharDet
310316
Detects the encoding of a text file using [UCharDet](https://www.freedesktop.org/wiki/Software/uchardet/).
311317
The list of supported encodings is described in the paragraph `Supported Languages/Encodings`.

src/DOpusScriptingExtensions/DOpusScriptingExtensions.idl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ interface IMediaInfoRetriever : IDispatch
5555
interface IExifTool : IDispatch
5656
{
5757
[id(1)] HRESULT GetInfoAsJson([in] BSTR fileFullName, [in, defaultvalue(0)] IDispatch* tagNamesJsArray, [out, retval] BSTR* infoAsJson);
58-
[id(2)] HRESULT Run([in] BSTR fileFullName, [in, defaultvalue(0)] IDispatch* commandLineArgs, [out, retval] BSTR* result);
58+
[id(2)] HRESULT Run([in] BSTR fileFullName, [in] IDispatch* commandLineArgs, [out, retval] BSTR* result);
59+
[id(3)] HRESULT RunArgs([in] IDispatch* commandLineArgs, [out, retval] BSTR* result);
5960
};
6061

6162
[object, uuid(EA478603-BB0E-4024-9308-FC147D0443F4), dual, nonextensible, pointer_default(unique)]

src/DOpusScriptingExtensions/ExifTool/ExifTool.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ class ATL_NO_VTABLE CExifTool :
3030
return S_OK;
3131
} CATCH_ALL_EXCEPTIONS()
3232

33+
STDMETHOD(RunArgs)(IDispatch* commandLineArgs, BSTR* result) override try {
34+
*result = Copy(
35+
exifToolWrapper->RunArgs(ToUtf8StringVector(JsStringArrayToVector(commandLineArgs))));
36+
return S_OK;
37+
} CATCH_ALL_EXCEPTIONS()
38+
3339
private:
3440
ExifToolWrapper* exifToolWrapper;
3541
};

src/DOpusScriptingExtensions/ExifTool/ExifToolCommandArgsGenerator.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
// ExifTool requires so that each argument should be separated by a newline character.
55
class ExifToolCommandArgsGenerator : boost::noncopyable {
66
public:
7+
ExifToolCommandArgsGenerator() = default;
8+
79
ExifToolCommandArgsGenerator(const std::wstring_view filePath) {
810
if (!std::filesystem::exists(filePath)) {
911
THROW_WEXCEPTION(L"File not found '{}'", filePath);

src/DOpusScriptingExtensions/ExifTool/ExifToolWrapper.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ class ExifToolWrapper : boost::noncopyable {
4949
return Execute(argsGenerator.GenerateExifToolInput());
5050
}
5151

52+
std::wstring RunArgs(const std::vector<std::string>& commandLineArgs) {
53+
ExifToolCommandArgsGenerator argsGenerator;
54+
argsGenerator.AddCommandLineArgs(commandLineArgs);
55+
return Execute(argsGenerator.GenerateExifToolInput());
56+
}
57+
5258
private:
5359
std::wstring Execute(const std::string_view exifToolCommands) {
5460
ioCtx.restart();

src/Test/test.js

420 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)