2

I want to remove leading path information using -replace. but no luck.

dir "C:\\IT\Tool" -r | % { $_.FullName -replace "C:\\IT\Tool","" }  | out-file c:\temp\FolderList.txt

e.g my desired output :

\script.txt
\PROD\file.txt
\readme.txt

1 Answer 1

0

You probably just missed to escape the second path part (\Tool):

dir "C:\\IT\Tool" -r | % { $_.FullName -replace "C:\\IT\\Tool","" }  | out-file c:\temp\FolderList.txt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.