「Windows10」typeコマンドでファイルの中身を空にする方法

使用例1
ファイルの中身を確認
>type “C:\study\skill\bat\test.txt"
123
456
789
ファイルの中身を空にする
>type nul > “C:\study\skill\bat\test.txt"
>type “C:\study\skill\bat\test.txt

使用例2
バッチファイルで複数ファイルの中身を空にする

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
set del_dir ="C:/study/skill/bat/11"
type nul >"%del_dir%34.log"
type nul >"%del_dir%56.log"
set del_dir ="C:/study/skill/bat/11" type nul >"%del_dir%34.log" type nul >"%del_dir%56.log"
set del_dir ="C:/study/skill/bat/11"
type nul >"%del_dir%34.log"
type nul >"%del_dir%56.log"

 

Cmd

Posted by arkgame