@echo off & setlocal EnableDelayedExpansion del 1.txt /q del 2.txt /q for /f %%i in (*) do (echo %%~fzi >>1.txt) rem 将文件大小存储到1.txt for /f "tokens=1* delims= " %%a in (1.txt) do ( set "zer=%%a" set "pat=%%b" if !zer!
Conditional Logic on Files # 判断文件是否存在及文件类型 -a file exists. #文件存在 -b file exists and is a block special file. #文件存在,并且是块设备 -c file exists and is a character special file. ##文件存在,并且是字符设备 -d file exists and is a directory. #文件存在,并且是目录 -e file exists (ju
核心代码 #!/bin/sh myPath="/var/log/httpd/" myFile="/var /log/httpd/access.log" #这里的-x 参数判断$myPath是否存在并且是否具有可执行权限 if [ ! -x "$myPath"]; then mkdir "$myPath" fi #这里的-d 参数判断$myPath是否存在 if [ ! -d "$myPath"]; then
//JavaScript根据文件名判断文件类型 var imgExt = new Array(".png",".jpg",".jpeg",".bmp",".gif");//图片文件的后缀名 var docExt = new Array(".doc",".docx");//word文件的后缀名 var xlsExt = new Array(".xls"