PowerShell to create list of files & folders over 255 characters

I need a Powershell script to search a folder (d:\public\records) and output of a list of all of the files that have a combined path (directory path + filename) of over 255 characters.

WHY?
I am using RichCopy to transfer 1TB of data from server to server.  RichCopy crashes due to the file length limits. I must use RichCopy as it is the only tool that fulfills all of the requirements for this project. The directory I am checking contains a lot of data in tens of thousands of folders so workarounds like mapping a network drive to shorten the path will not work, there are just too many and I am not even sure where they are.

THANKS!
LVL 6
zeotechAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bryan ButlerCommented:
foreach ($x in dir d:\public\records) {
    if ($x.FullName.Length -gt 255) {
           $x.fullname
    }
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zeotechAuthor Commented:
0
Bryan ButlerCommented:
Just remember it doesn't check under dirs that are too long:

// Check if the directory length is valid, if the            
// directory is too long then there is no point testing            
// the sub folder/files until this is fixed.            

Also in the code:

* I doubt What I have done is a good way of doing it, but    
* works enough - if you have a better idea please go ahead.

I think my one liner was better as it checks all the files.
0
Bryan ButlerCommented:
Just remember it doesn't check under dirs that are too long:

// Check if the directory length is valid, if the            
// directory is too long then there is no point testing            
// the sub folder/files until this is fixed.            

Also in the code:

* I doubt What I have done is a good way of doing it, but    
* works enough - if you have a better idea please go ahead.

I think my one liner was better as it checks all the files.
0
zeotechAuthor Commented:
Between this suggestion and the other code i can get the desired result.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.