Batch-script-cd

提供:Dev Guides
移動先:案内検索

バッチスクリプト-CD

このバッチコマンドは、別のディレクトリを変更したり、現在のディレクトリを表示したりするのに役立ちます。

構文

cd

次の例は、cdコマンドをさまざまな方法で使用する方法を示しています。

@echo off
Rem The cd without any parameters is used to display the current working directory
cd
Rem Changing the path to Program Files
cd\Program Files
cd
Rem Changing the path to Program Files
cd %USERPROFILE%
cd
Rem Changing to the parent directory
cd..
cd
Rem Changing to the parent directory two levels up
cd..\..
cd

出力

上記のコマンドは、さまざまなフォルダーの場所に変更した後、次の出力を表示します。

C:\Users\Administrator
C:\Program Files
C:\Users\Administrator
C:\Users
C:\