The script not find any esd file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Locked
Message
Author
balubeto
Posts: 136
Joined: 08 Dec 2011 12:14

The script not find any esd file

#1 Post by balubeto » 19 Jul 2016 11:06

I modified your script in this way

Code: Select all

@echo off &setlocal DisableDelayedExpansion
::http://www.dostips.com/forum/viewtopic.php?p=47747#p47747
:: Post subject: Validity of the directories and files names
::Posted: Wed Jul 13, 2016 12:26 pm by balubeto
::modified: Thu Jul 14, 2016 by thefeduke adding create as optional

Set "MaxRC=0"
call :VetDir "Windows_Files_Path" "Enter the directory in which put the content of the Windows Setup Media volume image:"
If "%errorlevel%" GTR "%MaxRC%" Set "MaxRc=%errorlevel%"
call :VetDir "iso_Path" "Enter the directory in which put the iso image file created:"
If "%errorlevel%" GTR "%MaxRC%" Set "MaxRc=%errorlevel%"
call :VetDir "esd_File_Path" "Enter the directory in which put the esd unencrypted file:"
If "%errorlevel%" GTR "%MaxRC%" Set "MaxRc=%errorlevel%"
call :VetDir "esd_Genuine_File_Path" "Enter the directory of the esd genuine unencrypted file:"
If "%errorlevel%" GTR "%MaxRC%" Set "MaxRc=%errorlevel%"
If "%errorlevel%" EQU "0" (
  call :VetFile "esd_File" "Enter the file to be converted which should be put in the %esd_Genuine_File_Path% directory:" "%esd_Genuine_File_Path%"
)
If "%errorlevel%" GTR "%MaxRC%" Set "MaxRc=%errorlevel%"

Echo.
If "%MaxRC%" NEQ "0" Echo.iso build abandoned during validation.
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%"

goto :eof

:VetDir
setlocal DisableDelayedExpansion
::http://www.dostips.com/forum/viewtopic.php?p=47682#p47682
:: Post subject: Re: Check the validity of the directories and files names
::Posted: Sun Jul 10, 2016 5:07 pm by aGerman
::modified: Thu Jul 14, 2016 by thefeduke adding create as optional

:loop
set "%~1="
set /p "%~1=%~2 "
call :validate "%~1" validpath
if errorlevel 2 Exit /b 1
if errorlevel 1 goto loop

call echo Valid path: "%validpath%"
rem.pause
endlocal &set "%~1=%validpath%"
exit /b

:validate
setlocal EnableDelayedExpansion
set "p=!%~1!"

:: characters /<>|*?" are invalid
for /f delims^=/^<^>^|*?^" %%i in ("!p!") do (
  setlocal DisableDelayedExpansion
  set "s=%%i"
  setlocal EnableDelayedExpansion
  if "!s!" neq "!p!" (
    endlocal&endlocal&endlocal
    echo Invalid character found.
    exit /b 1
  )
  endlocal&endlocal
)

:: if the 2nd and 3rd characters are not :\ it's not a local absolute path
if "!p:~1,2!" neq ":\" (
  endlocal
  echo No absolute path entered.
  exit /b 1
)

:remove_trailing_backslash if any
if "!p:~-1!"=="\" (set "p=!p:~,-1!"&goto remove_trailing_backslash)

:: check if the path exists
if not exist "!p!\" (
  echo The entered path doesn't exist.
  Call CHOICE /C BRC /N /M "Press B to Build, R to Retry with a different path or C to Cancel."
  If "!errorlevel!" EQU "3" (
    endlocal &set "%~2="
    exit /b 2
  )
  If "!errorlevel!" EQU "2" (
    endlocal
    exit /b 1
  )
  If "!errorlevel!" EQU "1" (
    mkdir !p!
  )
)

:: try to write a temporary file in order to check if you have permissions
2>nul (>"!p!\test.~tmp" type nul) || (
  endlocal
  echo Access denied.
  exit /b 1
)

:: file deletion fails if the path contains consecutive backslashes
2>nul del "!p!\test.~tmp" || (
  endlocal
  echo Multiple backslashes found.
  exit /b 1
)

endlocal &set "%~2=%p%"
exit /b 0

:VetFile
setlocal DisableDelayedExpansion
::http://www.dostips.com/forum/viewtopic.php?p=47682#p47682
:: Post subject: Re: Check the validity of the directories and files names
::Posted: Sun Jul 10, 2016 5:07 pm by aGerman
::modified: Thu Jul 15, 2016 by thefeduke - adding semi-autmatic file selection

set "folder=%~3"
set "files=0"
For /f "usebackq tokens=1-2" %%F in (`dir "%folder%" /a-d`) DO (
  If /I "%%~G" EQU "File(s)" Set "files=%%~F"
)
If "%files%" EQU "0" (Echo.No files in '%folder%'.&endlocal &set "%~1=" &Exit /b 1)
If "%files%" EQU "1" For /f "usebackq tokens=1" %%V in (`dir "%folder%" /b /a-d`) DO Set "Valid=%%V"
If "%files%" EQU "1" (
  Echo.'%valid%' is the only file in '%folder%'.
  endlocal &set "%~1=%valid%"
  Exit /b 0
)
dir "%folder%" /b /a-d
Echo.Enter one of the above files in '%folder%'.
:loopfile
set "%~1="
set /p "%~1=%~2 "
call :validatefile "%~1" validFile
if errorlevel 2 Exit /b 1
if errorlevel 1 goto loopfile

call echo Valid file: "%validfile%"
rem.pause
endlocal &set "%~1=%validfile%"
exit /b

:validatefile
setlocal EnableDelayedExpansion
set "p=!%~1!"

:: characters /<>|*?" are invalid
for /f delims^=/^<^>^|*?^" %%i in ("!p!") do (
  setlocal DisableDelayedExpansion
  set "s=%%i"
  setlocal EnableDelayedExpansion
  if "!s!" neq "!p!" (
    endlocal&endlocal&endlocal
    echo Invalid character found.
    exit /b 1
  )
  endlocal&endlocal
)

:: check if the file exists
if not exist "%folder%\!p!" (
  echo The entered file doesn't exist.
  Call CHOICE /C RC /N /M "Press R to Retry with a different file or C to Cancel."
  If "!errorlevel!" EQU "2" (
    endlocal &set "%~2="
    exit /b 2
  )
  If "!errorlevel!" EQU "1" (
    endlocal
    exit /b 1
  )
)

endlocal &set "%~2=%p%"
exit /b 0


but it does not find any esd file in the %esd_Genuine_File_Path% directory. Why?

Thanks

Bye

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: The script not find any esd file

#2 Post by foxidrive » 19 Jul 2016 11:24

Thread is locked. Please don't open new threads unless you provide information about your task.

Locked