Jump to content

strip names


Recommended Posts

hi, I'm trying to strip out pairs of names (none defined) holding different .ext, from inside a text file

Meaning; if a name appears more then once, Then it's name will get stripped regardless its extension

: index

France.pdf
En.txt
En.pdf
En.ini
.....

-after

:New_index

France.pdf

TIA

Edit: also, if this can be written without a subroutine to make it simpler ..

Edited by sweept
Link to comment
Share on other sites


This should work, but is untested. Working here as written below.

@ECHO OFF
SETLOCAL EnableDelayedExpansion
FOR /F "usebackq delims=" %%# IN ("index.txt") DO (
SET "bMoreThanOnce="
FOR /F "usebackq delims=" %%_ IN ("index.txt") DO (
IF /I "%%~n_"=="%%~n#" (
IF /I NOT "%%_"=="%%#" SET "bMoreThanOnce=Defined"
) )
IF NOT DEFINED bMoreThanOnce ECHO>>"New_index.txt" %%#
)

Edited by 5eraph
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...