@echo off title %~nx0 REM ******************************************************************** REM * Tool をダウンロードして展開 REM https://eu7w9wsmf6a74xyjdfzl3q-on.drv.tw/archives/commandline/00_Tool_download.bat.txt REM ******************************************************************** pushd %~dp0 set temp_dir=%temp%\%random% mkdir %temp_dir% set templist=%temp_dir%\templist.txt REM ##################################### REM ### ダウンロードするファイル名 REM ##################################### set FILE_unzipxN=unz600xn.exe set FILE_texinst=texinst2012.zip set FILE_UnxUtils=UnxUtils.zip set FILE_dd=dd-0.5.zip set FILE_vfd=vfd21-080206.zip set FILE_grub4dos=grub4dos-0.4.4.zip set FILE_grubinst=grubinst-1.1-bin-w32-2008-01-01.zip set FILE_cdrtools=cdrtools.zip set FILE_syslinux=syslinux-4.05.zip set FILE_unrarw32=unrarw32.exe set FILE_UniExtract=uniextract161_noinst.rar REM set FILE_= REM set FILE_= REM check toollist.txt if exist toollist.txt set toollist=%cd%\toollist.txt REM check url_list.txt if exist .\wget\url_list.txt set url_list=%cd%\wget\url_list.txt if exist url_list.txt set url_list=%cd%\url_list.txt REM check wget.exe if exist wget.exe set wgetexe=ok if exist .\wget\wget.exe set wgetexe=ok if "%toollist%"=="" GOTO NOTOOL if "%url_list%"=="" GOTO NOLIST if "%wgetexe%"=="" GOTO NOWGET REM directory check echo: setlocal enabledelayedexpansion for /f %%x in (toollist.txt) do dir /ad /b | findstr /x /i %%x || findstr !File_%%x! "%url_list%" >>"%templist%" REM ##################################### REM ### START REM ##################################### if not exist "%templist%" GOTO READY REM for /f "usebackq" %%x in (`dir /ad /b`) do set %%x=already for /d %%x in (*) do set %%x=already cls echo: echo ************************************************************** echo * === ツール関係のダウンロードと展開を始めちゃいます === * echo * !最大で【60 MB程】ダウンロードされます * echo * === wget.exe の準備はおk? === * echo ************************************************************** echo ================= 下記ツールを新規設定します ================= REM for /f %%x in (toollist.txt) do findstr /i %%x "%templist%" type "%templist%" echo ************************************************************** echo 続行しますか? 中断は xボタン or Ctrl-C echo: echo *** 何かキーを押すと続行します *** pause >nul REM ##################################### REM ### wget REM ##################################### set path=%cd%\wget;%path% set down_dir=%cd%\download_files echo: wget -nc -P "%down_dir%" --passive-ftp -i "%templist%" REM ##################################### REM ### 展開 REM ##################################### REM UNZIP ======================================== if exist .\unzipxN\unzip.exe set "path=%cd%\unzipxN;%path%" if "%unzipxN%"=="already" GOTO w32tex if not exist "%down_dir%\%FILE_unzipxN%" GOTO w32tex if exist "%down_dir%\%FILE_unzipxN%" mkdir unzipxN "%down_dir%\%FILE_unzipxN%" -d unzipxN\ if ERRORLEVEL 1 (set unzipxN=error) else (set unzipxN=done) echo: set path=%cd%\unzipxN;%path% echo: :w32tex REM W32TeX ====================================== if "%texinst%"=="already" GOTO unxutils if not exist "%down_dir%\%FILE_texinst%" GOTO unxutils if exist "%down_dir%\%FILE_texinst%" mkdir texinst unzip.exe "%down_dir%\%FILE_texinst%" -d .\texinst if ERRORLEVEL 1 (set texinst=error) else set texinst=done echo: :unxutils REM UnxUtils========================================= if "%UnxUtils%"=="already" GOTO ddexe if not exist "%down_dir%\%FILE_UnxUtils%" GOTO ddexe if exist "%down_dir%\%FILE_UnxUtils%" mkdir UnxUtils unzip.exe "%down_dir%\%FILE_UnxUtils%" -d .\UnxUtils if ERRORLEVEL 1 (set UnxUtils=error) else set UnxUtils=done echo: :ddexe REM dd ============================================ if "%dd%"=="already" GOTO vfd if not exist "%down_dir%\%FILE_dd%" GOTO vfd if exist "%down_dir%\%FILE_dd%" mkdir dd unzip.exe "%down_dir%\%FILE_dd%" -d .\dd if ERRORLEVEL 1 (set dd=error) else set dd=done echo: :vfd REM VFD ========================================= if "%vfd%"=="already" GOTO grub4dos if not exist "%down_dir%\%FILE_vfd%" GOTO grub4dos if exist "%down_dir%\%FILE_vfd%" mkdir vfd unzip.exe "%down_dir%\%FILE_vfd%" -d .\vfd if ERRORLEVEL 1 (set vfd=error) else set vfd=done echo: :grub4dos REM Grub4DOS ====================================== if "%grub4dos%"=="already" GOTO grubinst if not exist "%down_dir%\%FILE_grub4dos%" GOTO grubinst unzip.exe "%down_dir%\%FILE_grub4dos%" -d .\ if ERRORLEVEL 1 (set grub4dos=error) else set grub4dos=done REM ########## directory rename ########## ren grub4dos-0.4.4 grub4dos for /f "usebackq delims=" %%x in (`dir /ad/b ^| findstr grub4dos`) do set rename_grub=%%x if defined rename_grub ren %rename_grub% grub4dos REM ########## directory rename ########## echo: :grubinst REM grubinst ====================================== if "%grubinst%"=="already" GOTO cdrtools if not exist "%down_dir%\%FILE_grubinst%" GOTO cdrtools if exist "%down_dir%\%FILE_grubinst%" mkdir grubinst unzip.exe "%down_dir%\%FILE_grubinst%" -d .\grubinst if ERRORLEVEL 1 (set grubinst=error) else set grubinst=done echo: :cdrtools REM cdrtools ====================================== if "%cdrtools%"=="already" GOTO syslnx if not exist "%down_dir%\%FILE_cdrtools%" GOTO syslnx REM if exist "%down_dir%\%FILE_cdrtools%" mkdir cdrtools REM unzip.exe "%down_dir%\%FILE_cdrtools%" -d .\cdrtools unzip.exe "%down_dir%\%FILE_cdrtools%" -d .\ if ERRORLEVEL 1 (set cdrtools=error) else set cdrtools=done echo: :syslnx REM syslinux ====================================== if "%syslinux%"=="already" GOTO unrar if not exist "%down_dir%\%FILE_syslinux%" GOTO unrar if exist "%down_dir%\%FILE_syslinux%" mkdir syslinux unzip.exe "%down_dir%\%FILE_syslinux%" -d .\syslinux if ERRORLEVEL 1 (set syslinux=error) else set syslinux=done echo: :unrar REM unrar ====================================== if "%unrarw32%"=="already" GOTO uniex if not exist "%down_dir%\%FILE_unrarw32%" GOTO uniex if exist "%down_dir%\%FILE_unrarw32%" mkdir unrarw32 .\UnxUtils\usr\local\wbin\unrar.exe x "%down_dir%\%FILE_unrarw32%" .\unrarw32 if ERRORLEVEL 1 (set unraw32=error) else set unrarw32=done echo: :uniex REM Universal Extractor ====================================== if "%uniextract%"=="already" GOTO osouji if not exist "%down_dir%\%FILE_uniextract%" GOTO osouji if exist "%down_dir%\%FILE_uniextract%" mkdir uniextract set path=%cd%\unrarw32;.\UnxUtils\usr\local\wbin;%path% unrar.exe x "%down_dir%\%FILE_uniextract%" .\uniextract if ERRORLEVEL 1 (set uniextract=error) else set uniextract=done REM ##################################### REM ### 確認 REM ##################################### :osouji echo: echo ************************************************************** echo ダウンロードした書庫ファイルは展開しました echo: for /f %%x in (toollist.txt) do ( if "!%%x!"=="error" ( echo * でも !FILE_%%x! の展開に失敗したようです... )) for /f %%x in (toollist.txt) do ( if "!%%x!"=="done" ( echo * !FILE_%%x! を展開しました... )) REM ##################################### REM ### 削除 REM ##################################### echo: echo ************************************************************** echo ダウンロードした元の書庫ファイルを削除しますか? echo (書庫ファイル以外は削除しません) echo: echo Y(y) : 確認しながら削除 echo A(a) : すべて削除(前回分も含め) echo : 削除しないなら、そのまま Enter で echo: echo ************************************************************** echo: set /p select= [y,a, N]: echo: if /i "%select%"=="y" GOTO DEL_SEL if /i "%select%"=="A" GOTO DEL_ALL GOTO DONE :DEL_SEL for /f "useback tokens=2 delims==" %%x in (`set FILE_`) do ( if exist "%down_dir%\%%x" ( del /p "%down_dir%\%%x" )) GOTO DONE :DEL_ALL for /f "useback tokens=2 delims==" %%x in (`set FILE_`) do ( if exist "%down_dir%\%%x" ( del "%down_dir%\%%x" 2>nul )) GOTO DONE REM ##################################### REM ### ERROR REM ##################################### :NOTOOL echo: echo ============================================================== echo toollist.txt がありませんです... echo ============================================================== GOTO NOLIST :NOLIST if not "%url_list%"=="" GOTO NOWGET echo: echo ============================================================== echo url_list.txt がありませんです... echo ============================================================== GOTO NOWGET :NOWGET if "%wgetexe%"=="ok" GOTO NONFILE echo: echo ============================================================== echo wget.exe がありませんです... echo ============================================================== GOTO NONFILE :NONFILE echo: echo ! ファイルが足りないので中断します...! echo: GOTO END REM ##################################### REM ### おしまい REM ##################################### :READY echo: echo ============================================================== echo: echo 設定されているもの、 echo toollist.txt にあるものはすべて展開済みのようです。... echo: echo 終了イタシマス... echo: echo ============================================================== GOTO END :DONE echo: echo ============================================================== echo: echo 終了イタシマシタ... echo: echo ============================================================== GOTO END :END echo: echo *** 何かキーを押すと閉じます *** pause >nul rd /s /q "%temp_dir%"