You are not logged in.

#1 28 Jan 2019 10:51

BIGnotor
Member
Registered: 25 Jan 2019
Posts: 4

Format rows in txt

Hello everybody, big_smile

I want to format rows in a txt file, I don't know how I can :

In the txt file -> there is

"CN=ORD324,OU=Computer_Test,OU=Computers,DC=Company,DC=local"
"CN=ORD325,OU=Computer_Test,OU=Computers,DC=Company,DC=local"
"CN=ORD328,OU=Computer_Test,OU=Computers,DC=Company,DC=local"
"CN=ORD344,OU=Computer_Test,OU=Computers,DC=Company,DC=local"

I hope to format this in this :

ORD324
ORD325
ORD328
ORD344

If someone can show me  wink

Thank's

BIGnotor

Offline

#2 28 Jan 2019 14:53

RG
Member
From: Minnesota
Registered: 18 Feb 2010
Posts: 362

Re: Format rows in txt

Assuming text file is named Text.txt

@echo off
for /F "tokens=2 delims==," %%A in ('type Text.txt') do echo(%%A
pause

Windows Shell Scripting and InstallShield

Offline

#3 28 Jan 2019 15:10

BIGnotor
Member
Registered: 25 Jan 2019
Posts: 4

Re: Format rows in txt

It is not working, thank you for help

I've just find a solution, I use this methode, I don't know if it optimised but it's works

Assuming text file is named Text.txt too wink

SETLOCAL enableDelayedExpansion 
FOR /f "delims=" %%x IN ('TYPE Text.txt') DO (
	SET ORD=%%x
	ECHO Nom ORD = fichier text : !ORD!
	SET ORDformat=!ORD:~4,6!
	ECHO Nom ORD formate : !ORD!
	IF %ComputerName%==!ORDformat! (
	IF EXIST P:\ (
            NET USE P: /delete /yes)
	)else (
	    ECHO Bad Condition
	)
)
ENDLOCAL

And if I want, I write this in another text file smile

BIGnotor

Offline

Board footer

Powered by