本帖最后由 pcl_test 于 2015-2-21 21:05 编辑
回复 1# 思想之翼
1、合并数据- @echo off
- setlocal enabledelayedexpansion
- title 合并数据
- cd /d "D:\数据1\"
- set "fdir=D:\数据2\"
- if not exist "%fdir%" md "%fdir%"
- for /l %%i in (1001 1 1210) do (
- set num=%%i
- set num=!num:~1!
- copy "!num!_1.txt" "%fdir%!num!.txt"
- for /l %%j in (2 1 6) do (
- for /f "delims=" %%a in ('type "%fdir%!num!.txt"') do (
- for /f "delims=" %%b in ('type "!num!_%%j.txt"') do (
- >>$ echo,%%a%%b
- )
- )
- move $ "%fdir%!num!.txt"
- )
- )
- pause
复制代码 2、去除每行合并数据中的重复数字并排序- @echo off
- setlocal enabledelayedexpansion
- title 去除每行合并数据中的重复数字并排序
- cd /d "D:\数据2\"
- for /f "delims=" %%a in ('dir /b *.txt') do (
- for /f "delims=" %%b in ('type "%%a"') do (
- >$1 echo,%%b
- >$2 echo 1234567890
- set /p num=<$2
- for /l %%b in (0 1 9) do (
- findstr "%%b" "$1" >nul 2>nul || (>$2 echo !num:%%b=!)
- set /p num=<$2
- )
- >>$3 echo,!num!
- )
- move /y $3 "%%a"
- )
- del $*
- pause
复制代码 3、取反集(未出现的数)并排序- @echo off
- setlocal enabledelayedexpansion
- title 取反集(未出现的数)并排序
- cd /d "D:\数据2\"
- for /f "delims=" %%a in ('dir /b *.txt') do (
- for /f "delims=" %%b in ('type "%%a"') do (
- >$1 echo,%%b
- >$2 echo 1234567890
- set /p num=<$2
- for /l %%b in (0 1 9) do (
- findstr "%%b" "$1" >nul 2>nul && (>$2 echo !num:%%b=!)
- set /p num=<$2
- )
- echo "!num!"
- if /i "!num:~0,1!" == "e" (
- cd.>>$3
- ) else (
- >>$3 echo,!num!
- )
- )
- move /y $3 "%%a"
- )
- del $*
- pause
复制代码 4、去除每个文档里的重复行- @echo off
- title 去除每个文档里的重复行
- cd /d "D:\数据2\"
- for /f "delims=" %%a in ('dir /b *.txt') do (
- for /f "delims=" %%b in ('type "%%a"') do (
- if not defined %%b set %%b=PK & >>$ echo %%b
- )
- for /f "delims=" %%c in ('type $') do set %%c=<nul
- move $ "%%a"
- )
- pause
复制代码 5、提取数字- @echo off
- setlocal enabledelayedexpansion
- title 提取数字
- cd /d "D:\数据2\"
- for /f "delims=" %%a in ('dir /b *.txt') do (
- cd.>$
- for /f "delims=" %%b in ('type "%%a"') do (
- set "str=%%b"
- ::如果第三位数不为空
- if not "!str:~2,1!"=="" (
- ::如果第四位数为空,此处改为!str:~4,1!可提取3~4位的数
- if "!str:~3,1!"=="" (
- ::提取3位的数,调整相应的截取位置即可提取不同位数的数
- >>$ echo !str!
- )
- )
- )
- move $ "%%a"
- )
- pause
复制代码
|