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.

VB ScriptScripting LanguagesPowershell

Avatar of undefined
Last Comment
rimmena

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
soostibi

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
rimmena

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

So 000000000005506969 outputs to 556969

soostibi

Sorry, replace the 2nd line to:

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

Open in new window

rimmena

ASKER
Now it's back to leaving all the zero's
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
soostibi

Sorry again, this is good now (I hope :-) )
$_ -replace "(?<=\\)0+(?=\d+\.tif)","" 

Open in new window

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
soostibi

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/
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
rimmena

ASKER
Thanks