本帖最后由 aloha20200628 于 2024-11-3 11:13 编辑
回复 16# luckboy45
以下去重的代码针对16楼的示例文件 2.txt(数据行均为全路径文件名),第2行代码专为删除 2.txt 中的空行和行尾空格...- @echo off &setlocal enabledelayedexpansion
- (for /f "tokens=* delims= " %%a in (2.txt) do echo,%%~dpnxa)>0.0
- (for /f "delims=" %%a in ('sort 0.0') do (
- if /i "%%a" neq "!a!" if "!a!" neq "" echo,!a!)&set "b=!a!"&set "a=%%a")>2.new.txt
- if /i "!b!" neq "!a!" echo,!a!>>2.new.txt
- del/q "0.0"&endlocal&pause&exit/b
复制代码 以下代码未用 sort.exe 完成,但仍须第2行代码专为删除 2.txt 中的空行和行尾空格...- @echo off &setlocal enabledelayedexpansion
- (for /f "tokens=* delims= " %%a in (2.txt) do echo,%%~dpnxa)>0.0
- (for /f "delims=" %%a in (0.0) do if not defined _%%a set "_%%a=1"&echo,%%a)>2.new.txt
- del/q "0.0"&endlocal&pause&exit/b
复制代码
|