sweept

strip names

3 posts in this topic

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
0

Share this post


Link to post
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
0

Share this post


Link to post
Share on other sites

I couldn't have managed this without your help.

100% worth's of understanding and help effort.

Thank you 5eraph :)

0

Share this post


Link to post
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.