Link to home
Start Free TrialLog in
Avatar of rimmena
rimmena

asked on

Stripping out 0's from a file

I have a text file file with multiple entries in the following format:

TEST|1111110000|11111111111111| |\\server-01.home.org\images\small_images\IMG_000\000000005983592.tif|HOME|78787878
TEST|1111110000|11111111111111| |\\server-01.home.org\images\small_images\IMG_000\000009995983592.tif|HOME|78787878

My issue is that I need to strip out the leading 0's from the .tif file name throughout the file, but the file name does not always have the
same amount of leading 0's. Looking for a script that can do this.

ASKER CERTIFIED SOLUTION
Avatar of soostibi
soostibi
Flag of Hungary image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rimmena
rimmena

ASKER

Have found one issue with this, it strips the zero out of the file name as well.

So 000000000005506969 outputs to 556969

Sorry, replace the 2nd line to:

$_ -replace "^0+(?=\d+\.tif)",""

Open in new window

Avatar of rimmena

ASKER

Now it's back to leaving all the zero's
Sorry again, this is good now (I hope :-) )
$_ -replace "(?<=\\)0+(?=\d+\.tif)","" 

Open in new window

Avatar of rimmena

ASKER

That is fantastic thanks for your help and timely response with this, much appreciated.

Can you advise on a good book to learn powershell, I have some VB Script experience ?

Thanks Again
Read this one first: http://manning.com/payette2/
Maybe you'll not understand all at the first time, but go through, try the examples and then read it again from the beginning. The second time you'll understand all.

Then read this, maybe not from the beginning till the end, but read the topics you are interested in:
http://oreilly.com/catalog/9780596801519/
Avatar of rimmena

ASKER

Thanks