From bb7bab403e2ef2ada0ffd25c3f982da6294a4a08 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Mon, 14 Oct 2024 13:01:27 -0500 Subject: [PATCH] File metadata extraction. --- src/MiniDocs/FileLocator.extension.st | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/MiniDocs/FileLocator.extension.st b/src/MiniDocs/FileLocator.extension.st index 2ea48bb..939380e 100644 --- a/src/MiniDocs/FileLocator.extension.st +++ b/src/MiniDocs/FileLocator.extension.st @@ -23,6 +23,30 @@ FileLocator class >> atAlias: aString put: aFolderOrFile [ ^ updatedAliases ] +{ #category : #'*MiniDocs' } +FileLocator >> extractMetadata [ +"I package the functionality from [[How to extract meta information using ExifTool]], +from the GToolkit Book. +I depend on the external tool ExifTool." + + | process variablesList | + process := GtSubprocessWithInMemoryOutput new + command: 'exiftool'; + arguments: { self fullName}. + process errorBlock: [ :proc | ^ self error: 'Failed to run exiftool' ]. + process runAndWait. + variablesList := process stdout lines collect: [ :currentLine | + | separatorIndex name value | + separatorIndex := currentLine indexOf: $:. + name := (currentLine copyFrom: 1 to: separatorIndex - 1) trimBoth. + value := (currentLine + copyFrom: separatorIndex + 1 + to: currentLine size) trimBoth. + name -> value + ]. + ^ variablesList asOrderedDictionary +] + { #category : #'*MiniDocs' } FileLocator class >> fileAliases [ ^ MiniDocs appFolder / 'fileAliases.ston'