1

I am working on a batch script to automate building a Qt project.

One issue i am having is the fact that the install directory path of Qt may not be the same for every user.

For example, on my system the path of my mingw48_32 is: c:\Qt\Qt5.2.0\5.2.0\mingw48_32 but on someone elses system it may be c:\Qt\5.2.0\mingw48_32 depending on how they chose to set it up.

So when i am specifying the path for the qmake.exe, i need to know that the path to qmake.exe is.

How can i search for a file, and copy its path from a batch script?

Cody Pritchard
  • 635
  • 1
  • 9
  • 28
  • possible duplicate of [Find file and return full path using a batch file](http://stackoverflow.com/questions/13876771/find-file-and-return-full-path-using-a-batch-file) – alariva Jul 22 '15 at 23:47
  • You can take a look at this ==> http://stackoverflow.com/questions/31087866/batch-scripts-find-and-copy-file-from-unknown-directory/31093092#31093092 – Hackoo Jul 23 '15 at 00:18

1 Answers1

0

whence.bat

Not really like the real whence, but it might be helpful.

@SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
@SET EXITCODE=1

:: Needs an argument.

@IF "x%1"=="x" (
    @ECHO Usage: %0 ^<progName^>
    GOTO TheEnd
)

@set newline=^


@REM Previous two (2) blank lines are required. Do not change!

@REM Ensure that the current working directory is first
@REM because that is where DOS looks first.
@PATH=.;!PATH!

@FOR /F "tokens=*" %%i in ("%PATH:;=!newline!%") DO @(
    @IF EXIST %%i\%1 (
        @ECHO %%i\%1
        @SET EXITCODE=0
    )

    @FOR /F "tokens=*" %%x in ("%PATHEXT:;=!newline!%") DO @(
        @IF EXIST %%i\%1%%x (
            @ECHO %%i\%1%%x
            @SET EXITCODE=0
        )
    )
)

:TheEnd
@EXIT /B %EXITCODE%
lit
  • 14,456
  • 10
  • 65
  • 119