Solved

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

Posted on 2013-07-01
5
327 Views
Last Modified: 2013-07-02
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
Comment
Question by:firmapost
  • 2
  • 2
5 Comments
 
LVL 42

Expert Comment

by:sedgwick
ID: 39290113
u need to update the csv file?
can u explain?
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39290133
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
 

Author Comment

by:firmapost
ID: 39291811
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
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 39292266
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
 

Author Comment

by:firmapost
ID: 39292606
In colum nr2 theres Computer Asset.
No headers.

Just :

row 1 |row 2
mac    | asset


Ps script worked butifully :) Thank you
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question