asked on
@echo off
set test=1,2,4,1,5,6,2,3
ASKER
@ECHO OFF
set test=1,2,4,1,5,6,2,3
del tmp.txt >nul
del tmp_sorted.txt >nul
for %%a in (%test%) do echo %%a>>tmp.txt
for /f "delims=" %%F in ('sort tmp.txt') do (
set "curr=%%F"
setlocal enabledelayedexpansion
if "!prev!" neq "!curr!" echo !curr! >>tmp_sorted.txt
endlocal
set "prev=%%F"
)
setlocal EnableDelayedExpansion
set "txt="
set input=tmp_sorted.txt
for /f "delims=" %%a in (%input%) do (
set "txt=!txt!%%a,"
)
set "txt=!txt:~0,-1!"
>new.txt echo !txt!
del tmp.txt >nul
del tmp_sorted.txt >nul
ASKER
ASKER
Could Not Find c:\chef\tmp.txt
Could Not Find c:\chef\tmp_sorted.txt
Batch files are text files containing a script of commands that are executed by the command interpreter on DOS, OS/2 and Windows systems. Most commonly, they are used to perform a series of functions that are repeated -- copying a set of files created daily with one step, for example.
TRUSTED BY
Open in new window