![Windows: ディレクトリ内のファイルに関する情報をタブ区切りでリスト化する方法](https://rvso.com/image/1645756/Windows%3A%20%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%E5%86%85%E3%81%AE%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%81%AB%E9%96%A2%E3%81%99%E3%82%8B%E6%83%85%E5%A0%B1%E3%82%92%E3%82%BF%E3%83%96%E5%8C%BA%E5%88%87%E3%82%8A%E3%81%A7%E3%83%AA%E3%82%B9%E3%83%88%E5%8C%96%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95.png)
Linux ユーザーとして、Windows で次の問題を解決する方法がわかりません (cmd.exe を使用)。
指定されたディレクトリ内のすべてのファイルを、タブで区切られた次の情報とともに再帰的にリストします。
- フルパス
- ファイル名なしのフルパス
- ファイル名
- ファイルサフィックス
- 最終変更のタイムスタンプ
- 最近ファイルを操作したユーザー
例えば
c:\folderA\file1.txt<tab>c:\folderA<tab>file1.txt<tab>txt<tab>2016-02-18 15:18:29 +0100<tab>USER_X
c:\folderA\file2.txt<tab>c:\folderA<tab>file2.txt<tab>txt<tab>2018-02-28 14:28:44 +0100<tab>USER_Y
c:\folderA\folderAA\file3.xlsx<tab>c:\folderA\folderAA<tab>file3.xlsx<tab>xslx<tab>2011-12-01 05:22:01 +0100<tab>USER_Z
名前にスペースが含まれるファイルやフォルダが存在する可能性があります。
何か提案はありますか? ありがとうございます!
答え1
使用パワーシェルの代わりにコマンドPowerShellコマンドGet-ChildItem
エイリアスを使用するGCI
フルコマンド:
gci -r | % { $_.Name,$_.FullName,$_.LastWriteTime -join ' ' } | Out-File YourOutputfile.txt
gci
取得-子アイテム
-r
再帰的
$_.Name
ファイル名
$_.FullName
ファイルのフルパス
同じ出力:
Get-ChildItem -r | % { $_.Name,$_.FullName,$_.LastWriteTime -join ' ' } | Out-File YourOutputfile.txt
それでも使用したい場合は、Entercmd
キーをfor /?
押してこのセクションを読んでください。
%~I - expands %I removing any surrounding quotes (")
%~fI - expands %I to a fully qualified path name
%~dI - expands %I to a drive letter only
%~pI - expands %I to a path only
%~nI - expands %I to a file name only
%~xI - expands %I to a file extension only
%~sI - expanded path contains short names only
%~aI - expands %I to file attributes of file
%~tI - expands %I to date/time of file
%~zI - expands %I to size of file
%~$PATH:I - searches the directories listed in the PATH
environment variable and expands %I to the
fully qualified name of the first one found.
If the environment variable name is not
defined or the file is not found by the
search, then this modifier expands to the
empty string
The modifiers can be combined to get compound results:
%~dpI - expands %I to a drive letter and path only
%~nxI - expands %I to a file name and extension only
%~fsI - expands %I to a full path name with short names only
%~dp$PATH:I - searches the directories listed in the PATH
environment variable for %I and expands to the
drive letter and path of the first one found.
%~ftzaI - expands %I to a DIR like output line