rem 引数がない場合は終了する if "%~1"=="" (echo 引数がありません & pause & exit /b)
rem 変数初期化(長さ) set length=0
rem 長さ取得サブルーチンを実行 call :get_strlen %~1 echo 文字数:%length% exit /b
rem ====サブルーチン==== :get_strlen set str_in=%~1
:label_top rem 長さ加算 set /a length+=1 rem 1文字減らす set str_in=%str_in:~1% rem 文字列がなくなったら終了 if not "%str_in%"=="" (goto :label_top) exit /b 文字列長を取得する部分はサブルーチンにし、流用しやすくしました。 サブルーチンの中でループを回し、1文字削るごとにカウンタを+1します。 文字列がなくなったらループ終了し、そのときのカウンタの数値が文字列長です。
REM ファイル名を切り出す。 set FOURZE=%1 set WIZARD=!FOURZE! set /a n=1
:fileversing (set POP=!WIZARD:~-%n%,1!) if "!POP!"=="/" goto :filevesexit (set ENTRY=!POP!!ENTRY!) set /a n+=1 goto :fileversing
:filevesexit setlocal enabledelayedexpansion
SET DATIME=%DATE%%TIME% SET DATIME=%DATIME:~0,4%%DATIME:~5,2%%DATIME:~8,2%~%DATIME:~10,2%%DATIME:~13,2%%DATIME:~16,2%%DATIME:~19,2% SET DATIMES=%%DATIME: =0%
ECHO %ENTRY% ECHO %DATIME% chcp 932 INET_GET -f %DATIME%%ENTRY% -r 5 -v -nr -t %FOURZE% -L %ENTRY%%DATIME%.LOG >NUL TYPE %ENTRY%%DATIME%.LOG | FIND "Last-Modified:"> %ENTRY%%DATIME%.TXT FOR /F "delims=" %%A IN (%ENTRY%%DATIME%.TXT) DO SET LASTMODIFIED=%%A
DEL %ENTRY%%DATIME%.TXT DEL %ENTRY%%DATIME%.LOG
set entry='%LASTMODIFIED:~29,2%'%LASTMODIFIED:~23,3%%LASTMODIFIED:~20,2%%LASTMODIFIED:~15,3%%LASTMODIFIED:~32,2%%LASTMODIFIED:~35,2%%LASTMODIFIED:~38,2%GMT#%ENTRY% ECHO %ENTRY%
setlocal enabledelayedexpansion
echo %n% ECHO %WIZARD% IF %WIZARD:~0,8%==https:// SET WIZARF=##%WIZARD:~8% IF %WIZARD:~0,7%==http:// SET WIZARF=##%WIZARD:~7% ECHO %WIZARF%
SET WIZARD=%WIZARF% SET WIZARD=%WIZARD:/=#% SET WIZARD=%WIZARD:.=_%
CALL :set_week SET WIZARNTRY=%WIZARD%%ENTRY%
INET_GET -r 5 -v -nr -t -f %WIZARNTRY% %FOURZE% touchin -c -sw %WIZARNTRY% touchin -a -sw %WIZARNTRY% rem AFTER 60 YEARS
ATTRIB +R %WIZARNTRY% CLS DIR /a:-d %WIZARNTRY% exit /b
:set_week set TODAY=%datime%
REM WHICH WEEK set /a h=%TODAY:~0,2% set /a y=%TODAY:~2,2% set m1=%TODAY:~5,1% set m2=%TODAY:~6,1% if "%m2%" equ "/" ( set /a m=m1 set /a d=%TODAY:~7,2% ) else ( set /a m=m1*10+m2 set /a d=%TODAY:~8,2% ) if %m%==1 ( set /a y-=1&set /a m+=12 ) if %m%==2 ( set /a y-=1&set /a m+=12 )
set /a week_value=( y + (y/4) + (h/4) - 2*h + (13*(m+1)/5) + d ) %% 7
if %week_value%==0 set WEEK=Sat if %week_value%==1 set WEEK=Sun if %week_value%==2 set WEEK=Bon if %week_value%==3 set WEEK=Cue if %week_value%==4 set WEEK=Ded if %week_value%==5 set WEEK=Ehu if %week_value%==6 set WEEK=Fri
REM ファイル名を切り出す。 set FOURZE=%1 set WIZARD=!FOURZE! set /a n=1
:fileversing (set POP=!WIZARD:~-%n%,1!) if "!POP!"=="/" goto :filevesexit (set ENTRY=!POP!!ENTRY!) set /a n+=1 goto :fileversing
:filevesexit setlocal enabledelayedexpansion
SET DATIME=%DATE%%TIME% SET DATIME=%DATIME:~0,4%%DATIME:~5,2%%DATIME:~8,2%~%DATIME:~10,2%%DATIME:~13,2%%DATIME:~16,2%%DATIME:~19,2% SET DATIMES=%%DATIME: =0% chcp 932
TYPE %ENTRY%%DATIME%.LOG | FIND "Last-Modified:"> %ENTRY%%DATIME%.TXT FOR /F "delims=" %%A IN (%ENTRY%%DATIME%.TXT) DO SET LASTMODIFIED=%%A
DEL %ENTRY%%DATIME%.* DEL %DATIME%%ENTRY%
set entry='%LASTMODIFIED:~29,2%'%LASTMODIFIED:~23,3%%LASTMODIFIED:~20,2%%LASTMODIFIED:~15,3%%LASTMODIFIED:~32,2%%LASTMODIFIED:~35,2%%LASTMODIFIED:~38,2%GMT#%ENTRY%
setlocal enabledelayedexpansion
IF %WIZARD:~0,8%==https:// SET WIZARF=_%WIZARD:~8% IF %WIZARD:~0,7%==http:// SET WIZARF=_%WIZARD:~7%
SET WIZARD=%WIZARF%
REM ドメインの取得
set /a n=1 SET DOMAIN= SET PIECE= set POP= setlocal enabledelayedexpansion
:domain if "!POP!"=="/" goto :domainexit SET WIZARD=!WIZARD:~1! set POP=!WIZARD:~0,1! if "!POP!"=="." ( SET DOMAIN=!PIECE!_!DOMAIN! SET PIECE= goto :domain ) SET PIECE=!PIECE!!POP! set /a n+=1 goto :domain
:domainexit SET DOMAIN=#!PIECE:/=_!!DOMAIN! SET WIZARD=!DOMAIN!!WIZARD! SET WIZARD=%WIZARD:_/=##% SET WIZARD=%WIZARD:/=#% SET WIZARD=%WIZARD:.=_%
SET WIZARNTRY=%WIZARD%%ENTRY%
INET_GET -r 5 -v -nr -t -f %WIZARNTRY% %FOURZE% touchin -c -sw %WIZARNTRY% touchin -a -sw %WIZARNTRY% rem AFTER 60 YEARS