Solved How to delete repetitve lines using batch?

February 16, 2014 at 20:17:28
Specs: Windows 7
I was wondering if there's a batch command that can automatically delete any lines in a .txt file that occur more than once
Eg:

g:\win\pcs\a\n3.jpg
g:\win\pcs\a\n3.jpg
g:\win\pcs\a\n3.jpg
g:\win\pcs\a\n45.jpg
g:\win\pcs\a\n45.jpg

The final result should have only 2 lines left.
g:\win\pcs\a\n3.jpg
g:\win\pcs\a\n45.jpg


Thanks for your help.


See More: How to delete repetitve lines using batch?

Report •

#1
February 17, 2014 at 11:48:47
✔ Best Answer
::====== script starts here ===============
::
:: ssinside.bat 2014-02-18 2:45:16.00
@echo off > NEWFILE & setLocal enableDELAYedeXpansioN

:main
for /f "tokens=* delims= " %%a in (myfile) do (
find "%%a" < NEWFILE > nul || >> NEWFILE echo.%%a
)
goto :eof
::====== script ends here =================

=====================
M2 Golden-Triangle


Report •
Related Solutions


Ask Question