Newsroom Update

Beginning in May, a special Today at Apple series titled “Made for Business” will offer small business owners and entrepreneurs free opportunities to learn how Apple products and services can support their growth and success. Learn more >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Listing files with long names or paths (255 chars or more)

Hi all,

I've been given the task of moving the data off our mac file servers to a windows server, and this introduces the issue of long file/path names.

http://vlaurie.com/computers2/Articles/filenames.htm

Just wondering if there is a program or terminal command I can run, that will list all files that either have names too long, or have a name/path combination that is too long, so I can go and rename/action them?

Multiple XServes, Mac OS X (10.6.4)

Posted on Sep 22, 2010 9:49 PM

Reply
Question marked as Best reply

Posted on Sep 22, 2010 10:46 PM

find . -name \* -type f | perl -ne 's/(.*)/print length($1), " $1\n"/e' | sort -nu

Find files of any name starting from here (your current working directory), pass to Perl regular expression which replaces the entire line with the length of the line and the original line, thus making it ready for the sort (numerical, biggest last).
10 replies
Question marked as Best reply

Sep 22, 2010 10:46 PM in response to Bizarro

find . -name \* -type f | perl -ne 's/(.*)/print length($1), " $1\n"/e' | sort -nu

Find files of any name starting from here (your current working directory), pass to Perl regular expression which replaces the entire line with the length of the line and the original line, thus making it ready for the sort (numerical, biggest last).

Sep 29, 2010 6:50 PM in response to Bizarro

The only bug I have found with this command is that it doesn't appear to report multiple files/paths with the same length.
Eg if there is two files with a path length of 272 characters, only 1 will appear in the results. Once you correct that filename and run the command again, the other one will appear.
Is there an easy fix? Cheers 🙂

Listing files with long names or paths (255 chars or more)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.