标题: [文本处理] [已解决]批处理如何批量分割文本文件? [打印本页]
作者: ysrr2011 时间: 2015-3-8 16:09 标题: [已解决]批处理如何批量分割文本文件?
- @echo off
- cd /d "D:\XSS"
- set file="+Q5.1.txt"
- set per=50
- for %%a in (%file%) do set "dpn=%%~dpna" & set "x=%%~xa"
- set /a count=per-1, n=0
- setlocal enabledelayedexpansion
- for /f "usebackq delims=" %%a in (!file!) do (
- set /a count+=1, n=count/per
- echo %%a>>"D:\SS\!n!.+Q5.1!x!"
- )
- EXIT
复制代码
以上代码对1个指定文件进行分割处理,输出为序号+原文件名。请问如何修改,可对一个文件夹所有文件进行相同分割处理?
作者: pcl_test 时间: 2015-3-8 16:32
回复 1# ysrr2011 - @echo off
- setlocal enabledelayedexpansion
- cd /d "D:\XSS"
- for %%a in (*.txt) do (
- set per=50
- set /a count=per-1, n=0
- for /f "delims=" %%b in ('type "%%a"') do (
- set /a count+=1, n=count/per
- if not exist "D:\SS\%%~na\" md "D:\SS\%%~na\"
- echo %%b>>"D:\SS\%%~na\!n!.%%~nxa"
- )
- )
- EXIT
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |