Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Photo

strip names

- - - - -

  • Please log in to reply
2 replies to this topic

#1
sweept

sweept

    Junior

  • Member
  • Pip
  • 69 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, 22 February 2013 - 04:55 PM.



How to remove advertisement from MSFN

#2
5eraph

5eraph

    Update Packrat

  • MSFN Sponsor
  • 1,150 posts
  • OS:XP Pro x64
  • Country: Country Flag

Donator

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, 22 February 2013 - 07:33 PM.


#3
sweept

sweept

    Junior

  • Member
  • Pip
  • 69 posts
I couldn't have managed this without your help.
100% worth's of understanding and help effort.
Thank you 5eraph :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users



How to remove advertisement from MSFN