Sightseer
Posts: 6
Re: Extracting the metadata in a useful format

Ok, added the option to create the nested subdirectories or not.  Save the new code as "GPMD2CSV.bat".  I've done limited testing, should work though.

 

Switches:

This is the name of the overall subdirectory.  If you don't need a subdirectory, just set "BatchOutputFolder=" to nothing.

 

:: Name of the folder that is created to output to (Optional)
Set BatchOutputFolder=GoPro Metadata Extract

 

 

This is the optional nested subdirectory by filename.  Set "Set IndividualSubDirs=No" and it won't make the inddividual subdirectories.

 

:: Make Individual Subdirectories for each file?  Type in Yes or No
Set IndividualSubDirs=Yes

 

 

Examples:

To Output to "<Source File Directory>\GoPro Metadata Extract\<Source File Name>\<FILES>" Set:

Set BatchOutputFolder=GoPro Metadata Extract
Set IndividualSubDirs=Yes

 

To Output to "<Source File Directory>\GoPro Metadata Extract\<FILES>" Set:

Set BatchOutputFolder=GoPro Metadata Extract
Set IndividualSubDirs=No

 

To Output to "<Source File Directory>\<Source File Name>\<FILES>" Set:

Set BatchOutputFolder=
Set IndividualSubDirs=Yes

 

To Output to "<Source File Directory>\<FILES>" Set:

Set BatchOutputFolder=
Set IndividualSubDirs=No

 

 

Copy the code below and save as "GPMD2CSV.bat":

 

@ECHO OFF

:: Name of the folder that is created to output to (Optional)
Set BatchOutputFolder=GoPro Metadata Extract

:: Make Individual Subdirectories for each file?  Type in Yes or No
Set IndividualSubDirs=Yes

:: ==========================================
:: You shouldn't need to edit below this line
::===========================================

:IndividualSubDirCheck
if '%IndividualSubDirs%'=='Yes' goto IndSubDirY
if '%IndividualSubDirs%'=='yes' goto IndSubDirY
if '%IndividualSubDirs%'=='Y' goto IndSubDirY
if '%IndividualSubDirs%'=='y' goto IndSubDirY
if '%IndividualSubDirs%'=='No' goto IndSubDirN
if '%IndividualSubDirs%'=='no' goto IndSubDirN
if '%IndividualSubDirs%'=='N' goto IndSubDirN
if '%IndividualSubDirs%'=='n' goto IndSubDirN
Goto IndividualSubDirCheckError

:IndSubDirY
Set IndividualSubDirs=1
GoTo RunIt

:IndSubDirN
Set IndividualSubDirs=0
GoTo RunIt

:RunIt

Set SourceScriptDirectory=%~dp0
Set SourceFile=%1

cd "%~dp1"

If '%IndividualSubDirs%'=='1' (
	If exist ".\%BatchOutputFolder%\%~n1\%~n1".gpx goto :eof
) Else (
	If exist ".\%BatchOutputFolder%\%~n1".gpx goto :eof )

mkdir "%~n1"
if [%1]==[] goto :eof
:loop
"%SourceScriptDirectory%\bin\ffmpeg" -i "%~1" > output.txt 2>&1
for /F "delims=" %%a in ('FINDSTR "gpmd" output.txt') do set line=%%a
echo "%line%"
set stream= %line:~12,3%
echo "%stream%"
CLS
ECHO.
ECHO **************************************************
ECHO **************** Processing file: ****************
ECHO "%~nx1"
ECHO ***************** In Directory: ******************
ECHO "%~dp1"
ECHO **************************************************
@ECHO ON
START "" /WAIT /MIN "%SourceScriptDirectory%bin\ffmpeg" -y -i "%~1" -codec copy -map "%stream%" -f rawvideo "%~n1".bin
START "" /WAIT /MIN "%SourceScriptDirectory%bin\gpmd2csv" -i "%~n1".bin -o "%~n1"/"%~n1".csv
START "" /WAIT /MIN "%SourceScriptDirectory%bin\gopro2json" -i "%~n1".bin -o "%~n1"/"%~n1".json
START "" /WAIT /MIN "%SourceScriptDirectory%bin\gps2kml" -i "%~n1".bin -a 1000 -f 3 -o "%~n1"/"%~n1".kml
START "" /WAIT /MIN "%SourceScriptDirectory%bin\gopro2gpx" -i "%~n1".bin -a 1000 -f 3 -o "%~n1"/"%~n1".gpx
DEL "%~n1".bin
DEL output.txt
Mkdir "%BatchOutputFolder%"

If '%IndividualSubDirs%'=='1' (
	Move /Y "%~n1" ".\%BatchOutputFolder%\"
) Else (
	Move /Y "%~n1\*" ".\%BatchOutputFolder%\"
	RMDIR /S /Q "%~n1\" )

shift
if not [%1]==[] goto loop
GoTo eof

:IndividualSubDirCheckError
cls
ECHO **********************************************************
ECHO ************************* ERROR **************************
ECHO ***** "IndividualSubDirs" is not formatted correctly *****
ECHO *** Check "GPMD2CSV.bat" and verify it is = Yes or No ****
ECHO **********************************************************
pause
exit