5

このバッチ コード:

    :: File name: jjlist.bat  (normally, must be in system path)
    ::
    :: Purpose:
    :: batch that lists date/time, justified size and full path and file name.
    :: that goes to the screen or into a named file in current directory (folder)
    ::
    :: To use, at the command line type:
    :: jjlist *.* [or *.jpg etc]
    ::  to direct output to screen.
    :: or
    :: jjlist *.* outfilename.txt
    ::
    :: author: eliasrk(at)gmail.com
    ::
    @echo off
    set outfile=%2
    if "%1x"=="x" goto :end
    if NOT "%2x"=="x" goto :out2file
    :
    :out2screen
    for /r %%I in (%1) do if NOT "%%~tI" == "" call :loop4screen "%%~tI" "%%~zI" "%%I"
    goto :end
    :
    :loop4screen
    set Sz=              %~2
    echo %~1 %Sz:~-10% %~3
    goto :end
    :
    :out2file
    for /r %%I in (%1) do if NOT "%%~tI" == "" call :loop4fileOut "%%~tI" "%%~zI" "%%~xI" "%%I"
    goto :end
    :
    :loop4fileOut
    set Sz=              %~2
    set Ex=%~3        x
    :echo %~1 %Sz:~-10% %Ex:~0,8% %~4 >> %outfile%
    echo %~1 %Sz:~-10% %~4 >> %outfile%
    goto :end
    :
    :end

これらのレジストリ キーが設定されている場合:

[various] "\Control Panel\International"  "iTime"="1"
[various] "\Control Panel\International"  "iTLZero"="1"
[various] "\Control Panel\International"  "sTimeFormat"="HH:mm:ss"
[various] "\Control Panel\International"  "sShortDate"="yyyy-MM-dd"

次の形式の日付文字列のソート可能なリストを作成します。

2013-04-16 13:35       1293  D:\Documents\T_Args\Drafts\2013_04_15\1st_circle_claim.txt
2013-04-16 11:51       2110  D:\Documents\T_Args\Drafts\2013_04_15\sources_01.txt
2012-10-08 10:45      13599  D:\Documents\T_Args\images_temp\taut_faq_working\new_tautology.txt
2013-02-05 12:54       8829  D:\Documents\T_Args\Popper\Objective_Knowledge\pages.txt
2013-02-05 11:36       8835  D:\Documents\T_Args\Popper\Objective_Knowledge\pages_org.txt

このバッチを書いてから、修正方法を知りたい 2 つの問題を発見しました。

1) ファイル名に「&」がある場合、& に続く文字列が「コマンド」として扱われたことを示すエラー メッセージが生成されます。そのようなファイル名を普通に扱ってほしいです。

2) リストされる dir 構造にいる場合、「jjlist *.doc」の出力は問題ありませんが、「jjlist d:\documents*.doc」のように完全修飾パスを指定すると、出力はありません。これは修正できますか?

助けてくれてありがとう。

4

2 に答える 2