我在网上找到一段读取视频长度的批处理代码?我想给他把显示的内容写到txt上面,请问改怎么弄呢?- /*&cls
- @echo off
- rem 获取视频的相关属性信息(文件名称、大小、时长)
- cd /d "%~dp0"
- set ext=*.mp4 *.mkv *.rmvb *.mov
- set "outfile=1.txt"
-
- type nul>"%outfile%"
- set "exefile=ffmpeg.exe"
- set "a=:##bcn+bathome+net#tool#ffmpeg,3.4.2#%exefile%"
- set "a=%a:#=/%"
- set "b=http%a:+=.%"
- if not exist "%exefile%" (
- echo;"%exefile%" not found
- echo;download from: %b% , and put them together
- goto end
- )
- for /f "delims=" %%a in ('dir /a-d/b %ext%') do (
- rem echo;"%%a"
- %exefile% -i "%%a" 2>&1|cscript -nologo -e:jscript "%~f0" "%%a"
-
- )
- :end
- echo;
- pause
- exit
- */
- var fso=new ActiveXObject('Scripting.FileSystemObject');
- var a='*',b='*',c='*',d='*',e='*',f='*';
- var file=fso.GetFile(WSH.Arguments(0));
- a='"'+file.Name+'"';
- b=formatsize(file.Size);
- c=formattime(file.DateCreated);
- while(!WSH.StdIn.AtEndOfStream){
- var line=WSH.StdIn.ReadLine();
- var m2=line.match(/ Duration *: *(\d+:\d+:\d+)/);
- if(m2){d=m2[1];}
- var m3=line.match(/ Stream #0:0.+?: *.*?, (\d+x\d+).*?(\d+(?:\.\d+)? fps)/);
- if(m3){e=m3[1];f=m3[2];}
- }
- WSH.echo(a+b+d);
- WSH
-
- function formattime(t){
- var dt=new Date(t);
- var ymd=dt.getFullYear()+'-'+add(dt.getMonth()+1)+'-'+add(dt.getDate());
- var hms=add(dt.getHours()+1)+':'+add(dt.getMinutes())+':'+add(dt.getSeconds());
- return ymd+' '+hms;
- }
-
- function formatsize(s){
- var size=s + 'B';
- if(s>=1073741824){
- size=(s/1073741824).toFixed(2) + 'GB';
- }else{
- if(s>=1048576){
- size=(s/1048576).toFixed(2) + 'MB';
- }else{
- if(s>=1024){
- size=(s/1024).toFixed(2) + 'KB';
- }
- }
- }
- return size;
- }
-
- function add(t){return Number(t)<10?'0'+t:t;}
复制代码
|