MSFN Forum: strip names - MSFN Forum

Jump to content


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

strip names batch Rate Topic: -----

#1 User is offline   sweept 

  • Junior
  • Pip
  • Group: Members
  • Posts: 61
  • Joined: 08-November 05

Posted 22 February 2013 - 03:34 PM

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 ..

This post has been edited by sweept: 22 February 2013 - 04:55 PM



#2 User is offline   5eraph 

  • Update Packrat
  • Group: Supreme Sponsor
  • Posts: 954
  • Joined: 04-July 05
  • OS:XP Pro x64
  • Country: Country Flag

Posted 22 February 2013 - 05:53 PM

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" %%#
)

This post has been edited by 5eraph: 22 February 2013 - 07:33 PM


#3 User is offline   sweept 

  • Junior
  • Pip
  • Group: Members
  • Posts: 61
  • Joined: 08-November 05

Posted 22 February 2013 - 08:40 PM

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

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy