#author("2019-03-17T11:53:05+00:00","default:haikikyou","haikikyou")
#author("2019-03-17T11:54:16+00:00","default:haikikyou","haikikyou")
[[Windows/コマンドプロンプト/コマンド]]
#contents
* 内容 [#oe62267c]
ファイルの名前を変更する。複数ファイルも可能。
* 使用方法 [#v6a45ae7]
#geshi(bash){{{
ren [<Drive>:][<Path>]<FileName1> <FileName2>
rename [<Drive>:][<Path>]<FileName1> <FileName2>
}}}
** オプション [#gcd4d148]
|オプション|説明|h
|FileName1|元のファイル名|
|FileName2|新しいファイル名|
* 使用例 [#u8ba97e5]
** 拡張子を一式変える [#e913fa1c]
#geshi(dos){{{
c:\test\docs>dir
ドライブ C のボリューム ラベルがありません。
ボリューム シリアル番号は 7241-A2C2 です
c:\test\docs のディレクトリ
2019/03/17 20:51 <DIR> .
2019/03/17 20:51 <DIR> ..
2019/03/17 20:51 6 bar.txt
2019/03/17 19:52 <DIR> downloads
2019/03/17 20:51 5 foo.txt
2019/03/17 20:51 8 hello.txt
2019/03/17 19:52 <DIR> pictures
3 個のファイル 19 バイト
4 個のディレクトリ 34,412,707,840 バイトの空き領域
c:\test\docs>rename *.txt *.out
c:\test\docs>dir
ドライブ C のボリューム ラベルがありません。
ボリューム シリアル番号は 7241-A2C2 です
c:\test\docs のディレクトリ
2019/03/17 20:52 <DIR> .
2019/03/17 20:52 <DIR> ..
2019/03/17 20:51 6 bar.out
2019/03/17 19:52 <DIR> downloads
2019/03/17 20:51 5 foo.out
2019/03/17 20:51 8 hello.out
2019/03/17 19:52 <DIR> pictures
3 個のファイル 19 バイト
4 個のディレクトリ 34,412,707,840 バイトの空き領域
}}}
ディレクトリ名を変更する。
** ディレクトリ名を変更する [#v63c55dc]
#geshi(dos){{{
c:\test\docs>dir
ドライブ C のボリューム ラベルがありません。
ボリューム シリアル番号は 7241-A2C2 です
c:\test\docs のディレクトリ
2019/03/17 20:51 <DIR> .
2019/03/17 20:51 <DIR> ..
2019/03/17 20:51 6 bar.txt
2019/03/17 20:52 <DIR> .
2019/03/17 20:52 <DIR> ..
2019/03/17 20:51 6 bar.out
2019/03/17 19:52 <DIR> downloads
2019/03/17 20:51 5 foo.txt
2019/03/17 20:51 8 hello.txt
2019/03/17 20:51 5 foo.out
2019/03/17 20:51 8 hello.out
2019/03/17 19:52 <DIR> pictures
3 個のファイル 19 バイト
4 個のディレクトリ 34,412,707,840 バイトの空き領域
c:\test\docs>rename *.txt *.out
c:\test\docs>rename downloads download
c:\test\docs>dir
ドライブ C のボリューム ラベルがありません。
ボリューム シリアル番号は 7241-A2C2 です
c:\test\docs のディレクトリ
2019/03/17 20:52 <DIR> .
2019/03/17 20:52 <DIR> ..
2019/03/17 20:51 6 bar.out
2019/03/17 19:52 <DIR> downloads
2019/03/17 19:52 <DIR> download
2019/03/17 20:51 5 foo.out
2019/03/17 20:51 8 hello.out
2019/03/17 19:52 <DIR> pictures
3 個のファイル 19 バイト
4 個のディレクトリ 34,412,707,840 バイトの空き領域
4 個のディレクトリ 34,412,642,304 バイトの空き領域
}}}
* 参考リンク [#led0bb9a]
- https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/ren