【Windows】Windowsコマンドにおけるファイルおよびディレクトリ操作

PUBLISHED 2023-09-04
UPDATED 2024-08-13

作成と削除

  • 空のファイルを作成

    C:\> echo. > newfile.txt
  • 新しいディレクトリを作成

    C:\> mkdir new_directory
  • ファイルを削除

    C:\> del file_to_remove.txt
  • ディレクトリを削除

    C:\> rmdir /s /q directory_to_remove

コピー、移動、および名前変更

  • ファイルをコピー

    C:\> copy source.txt destination.txt
  • ディレクトリをコピー

    C:\> xcopy /s /i source_directory destination_directory
  • ファイルやディレクトリを移動または名前を変更

    C:\> move oldname.txt newname.txt

一覧表示とナビゲーション

  • ディレクトリの内容をリスト

    C:\> dir
  • 現在のディレクトリを表示または変更

    C:\> cd \path\to\directory

ファイル内容の表示

  • ファイルの全内容を表示

    C:\> type file.txt
  • ページネーションを使用してファイルの内容を表示

    C:\> more file.txt

    (注: Windowsの基本的なコマンドプロンプトには、headtailコマンドに直接対応するものはありません。)

ファイルおよびディレクトリの情報

  • ファイルまたはディレクトリに関する詳細情報を表示

    C:\> dir file.txt

    (注: Windowsの基本的なコマンドプロンプトには、fileコマンドに直接対応するものはありません。)

ファイルの検索

  • ディレクトリ内のファイルを検索

    C:\> dir /s /b \path\to\search\*pattern*.txt
CATEGORY
TAGS
円