• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 337
  • Last Modified:

'Need Script to rename MAC addreses in a csv file.

Need  Script to rename MAC addreses from 0022446688 to 00-22-44-66-88 is a csv file or txt file.

Thank you in advance :)
0
firmapost
Asked:
firmapost
  • 2
  • 2
1 Solution
 
Meir RivkinFull stack Software EngineerCommented:
u need to update the csv file?
can u explain?
0
 
Scott Fell, EE MVEDeveloperCommented:
response.write newMac("0022446688")

function newMAC(x)
   newMac=left(x,2)&"-"&mid(x,3,2)&"-"&mid(x,6,2)&"-"&mid(8,2)&"-"&right(x,2)
end function

Open in new window

0
 
firmapostAuthor Commented:
Basically got a csv file that has 400 mac addresses in it , but i need the macs to look like 00-22-44-66-88 . So a macro to edit the cvs file or something.

macs are stored in the first column of the cvs file.
0
 
Meir RivkinFull stack Software EngineerCommented:
do u have any other columns in the csv?
do u have header in the csv?

if the file is just list of mac addresses then u can use this PS script:
$csv = gc c:\temp\result.csv
$csv | %{
	([regex]::matches($_, '.{2}') | %{$_.value}) -join '-'
} | sc c:\temp\result.csv

Open in new window

0
 
firmapostAuthor Commented:
In colum nr2 theres Computer Asset.
No headers.

Just :

row 1 |row 2
mac    | asset


Ps script worked butifully :) Thank you
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now