本帖最后由 pcl_test 于 2016-9-20 23:20 编辑
新建一个“文件列表.txt”,将excel表格B列列出的txt文本路径一行一个复制粘贴到“文件列表.txt”里- @echo off&setlocal enabledelayedexpansion
- for /f "delims=" %%a in ('type "文件列表.txt"') do (
- (set /p line=<"%%a"
- echo;!line:~,10!)>"New_%%~nxa"
- )
- pause
复制代码
- rem 第三方http://www.bathome.net/s/tool/index.html?key=gawk
- gawk "{fn=$0;sub(/^.+\\/,\"\",fn);getline<$0;print substr($0,1,10)>\"New_\"fn}" "文件列表.txt"
- pause
复制代码
- powershell -c "gc '文件列表.txt'|%%{$fn='New_'+[System.IO.Path]::GetFileName($_);(gc $_)[0][0..9] -join ''|out-file $fn}"
- pause
复制代码
- //&cls&cscript -nologo -e:jscript "%~f0"<"文件列表.txt"&pause&exit
-
- var fso = new ActiveXObject('Scripting.FileSystemObject');
- while(!WSH.StdIn.AtEndOfStream){
- var line = WSH.StdIn.ReadLine();
- try{
- var text = fso.OpenTextFile(line, 1).ReadLine();
- fso.CreateTextFile('New_'+line.replace(/^.+\\/, ''), 2).WriteLine(text.substr(0,10));
- }catch(e){WSH.echo(line+'文件为空或不存在')};
- }
复制代码
|