cmd命令使用备忘

批量复制文件到指定位置:

forfiles /S /M *.cs /C "cmd /c copy /Y @path d:\bigcs\all"

 

向所有文件写入相同的内容(hello,world):

forfiles /S /M *.txt /C "cmd /c echo hello,world > @path"

或者

for /F %i in ('dir /b *.txt') do @echo hello,world > %i

 

forfiles命令只在服务器版本中提供,XP中没有。

 

批量为字符串增加前缀和后缀,比如为字符串增加单引号和逗号(用于构造SQ查询的IN条件)

for /F %i in (a.txt) do @echo '%i',  >> b.txt

 

 

posted @ 2010-09-29 14:58  无待  阅读(224)  评论(0编辑  收藏  举报