%~sIã®ãã°ã«ã¤ãã¦
å æ¥äºåããéããnews:alt.msdos.batch.nt ã§çºè¦ãã ~s 修飾åã®ãã°ã«ã¤ãã¦ã
forå¤æ°ãããããå¼æ°ã«ã¯ã%~sI ã %~s1 ã¨ãã修飾åã§ã·ã§ã¼ããã¼ã (ã¾ãã¯8.3å½¢å¼ã以ä¸ã§ã¯SFNã¨æ¸ã)å½¢å¼ã®ãã¹åã»ãã¡ã¤ã«åãå¾ããã¨ãåºæ¥ãããããããã«ã¯ãã°ããããNT4æ代ãããã£ã¦ãç´ã£ã¦ããªããããããã®ãã°ã¯ç°¡åã«åç¾ã§ããã
md "long long long dir" cd "long long log dir" echo.>"A B.txt" for %%A in (*.txt) do echo %%~sA
æ¬æ¥ã¯ã\LONGLO~1\ABBE64~1.TXT ã®ããã«è¡¨ç¤ºãããã¹ãé¨åãã\LONGLO~1\ABBE64~1.TXTB.txt ã®ããã«å¾ãã«ãã¿(LFNã®æ®éª¸)ãä»ãã¦ãã¾ãã
ãããããã°ããã以ä¸ãç¹å®ã®ç°å¢ã§ä¸æçã«ä½¿ãããããªãã¨ããããæ±ç¨ãã¼ã«ãä½ãæ㯠~s 修飾åãå®æã«ä½¿ããªãã¨è¨ããã¨ã ã
解決æ³ã¨ãã¦ã¯ããã¹ã®ä¸ä½é¨åããé ã«SFNå½¢å¼ã«ãã¦ããããç¡ãããã ãæ±ç¨ãµãã«ã¼ãã³ :sfnsub ã¨ãã®(ä¸è¨ã¹ã¯ãªããã§ä½ã£ããã¡ã¤ã«ã§ã®)ãã¹ãã¹ã¯ãªããã示ãã:sfnsub ã®ä»æ§ã¨ãã¦ã¯ã" ã§å²ãã ãã«ãã¹ãå¼æ°ã«ããã¨ãç°å¢å¤æ° SFN ã«ãã®SFNãè¿ãã" ã§å¼æ°ãå²ãã®ã¯å¿ é ããªããããã¨æ¬¡ã®ã¹ã¯ãªããã¯ç§ã¨foxidriveæ°ã®åä½ã§ããã
@echo off setlocal for %%A in ("A B.txt") do @echo %%~sA&call :sfnsub "%%~fA" echo %SFN% goto :eof :sfnsub set ARG=%1 set ARG=%ARG:\=\" "% set SFN= call :loop %ARG% goto :eof :loop for %%A in ("%SFN%%~1") do set SFN=%%~sA shift if not "%~1"=="" goto :loop set "SFN=%SFN:&=^&%" set "SFN=%SFN:^^=^%" goto :eof
æ±ç¨ã¨æ¸ãããã% ã¯ã¹ã¯ãªããä¸ã§ãµãã«ã¼ãã³ã®å¼æ°ã¨ãã¦æ¸¡ããªã(注1)ã®ã§ % ãå«ãã ãã¡ã¤ã«åã¯é§ç®ã ããã以å¤ã®ãã¡ã¤ã«åã«ä½¿ããç¹æ®æåã«ã¯å¯¾å¿ãã¦ããã¯ãã (ã¾ã æ¼ãããããããããªãã)ããªãããã®æ¹æ³ã¨å¥ã« COMMAND.COM ã使ã£ã¦ã«ã¬ã³ããã£ã¬ã¯ããªã SFN ã«å¤æããå¥æ³ãããã
@echo off setlocal for %%A in ("A B.txt") do @echo %%~sA&call :sfnsub "%%~fA" echo %SFN% goto :eof :sfnsub pushd . cd /d "%~dp1" command /c rem for %%A in ("%~nx1") do set SFN=%%~sA popd goto :eof
ãã£ã¡ã®ã»ããããããããããã ããæ¥æ¬èªçWindowsã®å ´åã¯ååã®COMMAND.COMå®è¡æã«ç»é¢ãã¯ãªã¢ããã¦ããããã¡ãã»ã¼ã¸ãåºã(注2)ã®ã§ãã¾ãã¡ã§ããã
ãããã«ãããããSFNãå¾ãããã«å¤§ãããªè©±ã§ãããã¹ã¯ãªããã§ã¯SFNã使ãã®ãé¿ããã»ããããã ããã
\Program files\ ã®ä¸ã ã調ã¹ã¦ã¿ããã%~sI ãæ£ããçµæãè¿ããªããã¡ã¤ã«ã¯çµæ§ããã
(注1:ãã¡ããã% ã %%%% ã«ç½®æãã¦ããå¼æ°ã«ä½¿ãã°ããããforå¤æ°ã«ã¯ç½®æã使ããªãããç½®æããããã«ä¸è¬ã®ç°å¢å¤æ°ã«ä¸æ¦ã»ããããã°ããã«å¤ãã®åé¡ãå¼ãèµ·ããã®ã§ç¾å®çã§ãªã)
(注2:è±èªçã§ã¯åºãªããããããããåºããªãæ¹æ³ã¯ç¡ãã ãããï¼)