虽然赶脚不需要我了,但还是改着玩玩...- @set @n=0/*&echo off
- dir /b *.jpg | cscript -nologo -e:jscript "%~0" "格式化输出:高度[$height] 宽度[$width] 像素[$px] 文件[\'$file\']"
- rem 按指定格式输出取得的信息
- pause
-
- for /f "delims=" %%a in ('dir /b *.jpg ^| cscript -nologo -e:jscript "%~0"') do (
- echo 在这里对 %%a 做你想做的操作...
- )
- rem 处理示例
- pause &exit /b */
-
- var format = '$file'
- if(WScript.Arguments.length){
- format = WScript.Arguments.Item(0).replace(/\$\$/g,'{$$$$}')
- format = format.replace(/\\r/g,'\r')
- format = format.replace(/\\n/g,'\n')
- format = format.replace(/\\t/g,'\t')
- format = format.replace(/\\'/g,'"')
- }
-
- var Img = new ActiveXObject("WIA.ImageFile")
- var px
- var list = {px:0,files:[]}
-
- while(!WScript.StdIn.AtEndOfStream){
- var file = WScript.StdIn.ReadLine()
- Img.LoadFile(file)
-
- px = Img.Width * Img.Height
-
- if(px > list.px){
- list = {px:px,width:Img.Width,height:Img.Height,files:[file]}
- } else {
- list.files.push(file)
- }
- }
-
- var output = format.replace(/\$px/gi,list.px)
- output = output.replace(/\$height/gi,list.height)
- output = output.replace(/\$width/gi,list.width)
-
- for(var i in list.files){
- output = output.replace(/\$file/gi,list.files[i])
- WScript.Echo(output.replace(/\{\$\$\}/gi,'$$$$'))
- }
复制代码 支持简单的格式化输出 |