Easiest way to see if PATH contains ffmpeg Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
MikeyG12
Posts: 30
Joined: 03 May 2018, 14:21

Easiest way to see if PATH contains ffmpeg

17 Sep 2021, 18:07

Hello everyone,

I'm trying to check to see if the user has the ffmpeg path stored in the Windows Env and if they do, I want to store the ffmpeg file location in a variable to use later in the script. So far, I've gotten my script to read the Windows PATH and then store it in an Array but after that I can't figure out how to tell if the file path string stored in an Array object contains the word ffmpeg. Below is what I have so far:

Code: Select all

EnvGet, OutputVar, Path

Array := StrSplit(OutputVar, `;)
Length := Object.Length(Array)
Loop, Length
{
	if (Array[Length] = [I want to check if the string stored in this object contains the word ffmpeg]
     {
          ffmpegPath := Array[Length]
return
     }
     else 
     {
          ffmpegFound := true
return
     }
          
}

if (ffmpegFound == true) {
; store the file path into a variable
} else {
; Write script to install ffmpeg and add the file path to Windows Environment. Once that's done, store ffmpeg install location in variable.
}
return
This is what the OutputVar gets populated with when I run this script:

C:\Users\Gizmo\AppData\Roaming\ActiveState\bin;c:\ffmpeg\bin\;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\MKVToolNix;C:\youtube-dl;C:\Program Files\7-Zip\;C:\Program Files (x86)\GnuWin32\bin\;C:\Program Files\NASM;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\TortoiseSVN\bin;E:\Downloads\;C:\Program Files (x86)\dotnet\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\PuTTY\;C:\Program Files\Calibre2\;C:\Program Files\Git\cmd;C:\Users\Gizmo\adb-fastboot\platform-tools_r31.0.3-windows\platform-tools;C:\FFMPEG\bin;C:\Users\Gizmo\.dotnet\tools;C:\Users\Gizmo\AppData\Local\Microsoft\WindowsApps;C:\Program Files\7-Zip\;C:\Program Files (x86)\GnuWin32\bin;C:\Perl64\bin;C:\Program Files\NASM;C:\Users\Gizmo\.dotnet\tools;C:\Program Files (x86)\Nmap
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Easiest way to see if PATH contains ffmpeg  Topic is solved

17 Sep 2021, 18:22

Code: Select all

;~ EnvGet, OutputVar, Path

OutputVar =
(
C:\Users\Gizmo\AppData\Roaming\ActiveState\bin;c:\ffmpeg\bin\;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\MKVToolNix;C:\youtube-dl;C:\Program Files\7-Zip\;C:\Program Files (x86)\GnuWin32\bin\;C:\Program Files\NASM;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\TortoiseSVN\bin;E:\Downloads\;C:\Program Files (x86)\dotnet\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\PuTTY\;C:\Program Files\Calibre2\;C:\Program Files\Git\cmd;C:\Users\Gizmo\adb-fastboot\platform-tools_r31.0.3-windows\platform-tools;C:\FFMPEG\bin;C:\Users\Gizmo\.dotnet\tools;C:\Users\Gizmo\AppData\Local\Microsoft\WindowsApps;C:\Program Files\7-Zip\;C:\Program Files (x86)\GnuWin32\bin;C:\Perl64\bin;C:\Program Files\NASM;C:\Users\Gizmo\.dotnet\tools;C:\Program Files (x86)\Nmap
)

for each, path in StrSplit(OutputVar, ";") {
    if InStr(path, "ffmpeg") {
        ffmpegPath := path
        break
    }
}

MsgBox % ffmpegPath    ; = c:\ffmpeg\bin\
ExitApp
MikeyG12
Posts: 30
Joined: 03 May 2018, 14:21

Re: Easiest way to see if PATH contains ffmpeg

17 Sep 2021, 18:30

Thank you so much, this has been bugging me for the last couple of hours!!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: kshitij90 and 337 guests