- 展示文件夹下面的内容 dir
- 创建一个文件
(1)使用echo命令:在D盘下创建test.txt文本文件
D:\>echo Hellod World! >test.txt
(2)使用copy命令:copy con 文件名.扩展名
D:\>copy con test.txt
# 文件内容...
# 最后Ctrl+Z表示输入结束
- 一些文件的操作
(1)浏览文件内容: type 文件名.扩展名 | more
type test.txt
type test.txt | more # 分页显示(按空格显示下一页内容)
(2)修改文件名:ren 原文件名,扩展名 新文件.扩展名
ren test.txt try.txt
(3)复制文件:COPY 要复制的文件 复制后的文件
# 当前处于文件夹a和b的父文件夹中,将a中的test1.txt复制一份到b中,名字为test2.txt
copy ..\a\test1.txt ..\b\test2.txt
# 将b中的test2.txt复制一份到当前文件夹中,名字仍是test2.txt
cpoy ..\b\test2.txt .\
(4)移动文件:move 要移动的文件 移动后的文件
# 将a中的test1.txt文件移动到C盘根目录下
move ..\a\test1.txt C:\
- 删除文件:del 文件名.扩展名
del test.txt # 删除test.txt
del *.txt # 删除所有txt文件
del *.txt /q # 不要有提示,直接删除
- 创建文件夹 :md 文件夹名
- attrib 命令(既可以跟文件,也可以跟文件夹)
ATTRIB [+R | -R] [+A | -A ] [+S | -S] [+H | -H] [+I | -I]
[drive:][path][filename] [/S [/D] [/L]]
+ 设置属性
- 清除属性
R 只读文件属性
A 存档文件属性
S 系统文件属性
H 隐藏文件属性
I 无内容索引文件属性。
[drive:][path][filename] 指定 attrib 要处理的文件。
/S 处理当前文件夹及其所有子文件夹中的匹配文件。
/D 也处理文件夹。
/L 处理符号链接和符号链接目标的属性。
attrib +h test.txt # 隐藏文件test.txt
attrib -h test.txt # 取消隐藏
- 快速创建指定大小的空文件:futil file createnew
# 快速在c:\window下创建文件system.ini,大小为102400
fsutil file createnew c:\windows\system.ini 102400
# 将创建的文件设置为系统属性并隐藏(因为文件名很系统文件,再加上被隐藏,就神不知鬼不觉地占用了很大的空间)
attrib +s +a +h system.ini
- 修改关联:文件类型关联决定了用什么程序打开这些文件
assoc .txt = exefile #将所有的txt文件都作为exe文件执行(会变得无法执行)
assoc .txt = txtfile #将所有的txt文件都变回去
- shutdown命令
shutdown -s -t 时间(秒) # 定时关机
shutdown -s -f -t 时间(秒) # 定时强制关机
shutdown -r -t 时间(秒) # 定时重启
shutdown -r -f -t 时间(秒) # 定时强制重启
shutdown -a # 取消定时
shutdown -l # 注销,同logoff命令