I have this script
Code: Select all
@echo off
setlocal enableExtensions disableDelayedExpansion
call :setValidPath "Windows_Files_Path" "%~1" "Enter the directory in which put the content of the ""Windows Setup Media"" volume image:"
call :setValidPath "iso_Path" "%~2" "Enter the directory in which put the iso image file created:"
call :setValidPath "esd_File_Path" "%~3" "Enter the directory in which put the esd unencrypted file:"
call :setValidFile "esd_File" "%~4" "Enter the file to be converted which should be put in the %esd_File_Path% directory:"
echo(
echo Result:
echo Windows_Files_Path: "%Windows_Files_Path%"
echo iso_Path : "%iso_Path%"
echo esd_File_Path : "%esd_File_Path%"
echo esd_File : "%esd_File%"
:: put your code here
endlocal
goto :eof
:setValidPath
:: %~1 variable to set
:: %~2 default value
:: %~3 text if default value is invalid
setlocal
set "input=%~2"
set "text=%~3"
set "first=1"
:validatePath
set "invalid="
:: validating
:: example code for invalidating input if the given path does not exist
if not exist "%input%" set "invalid=The Path you specified for %~1 ^("%input%"^) does not exist."
:: insert code for additional validity checking
if not defined invalid endlocal & set "%~1=%input%" & echo Valid: %~1=%input%& goto :eof
echo(Invalid: %invalid%
set /P ^"input=%text:""="% "
goto :validatePath
:setValidFile
:: %~1 variable to set
:: %~2 default value
:: %~3 text if default value is invalid
setlocal
set "input=%~2"
set "text=%~3"
set "first=1"
:validateFile
set "invalid="
:: validating
:: example code for invalidating input if the given filename is empty string
if "" == "%input%" set "invalid=The Filename you specified for %~1 is the empty string."
:: insert code for additional validity checking
if not defined invalid endlocal & set "%~1=%input%" & echo Valid: %~1=%input%& goto :eof
echo(Invalid: %invalid%
set /P ^"input=%text:""="% "
goto :validateFile
that should check the validity of the directories (with absolute paths) and files names in Windows 7 and above and save these elements in the respective variables.
I noticed that if I insert some valid directories or files but non-existent, the values of these elements are not saved in these variables. Why?
The validity of these values is used to make sure that the creation of these elements have always success using the above variables with the md and oscdimg commands.
So, how can I modify this script?
Thanks
Bye