Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Dropbox tells me many of my files are not syncing because their name exceeds the max character length

Max character length

Windows only allows file and folder names of 260 characters or less. Note that Windows counts the file path as part of the name, so a file like C:\Users\Panda\My Documents\Dropbox\Creative Nonfiction\My Autobiography\Favorite Things\Favorite Foods\Bamboo\Family Recipes\Fresh Leaves.doc would be 142 characters, not 16. If the entire file path and name exceed 260 characters, shorten the name or move the file or folder to a higher-level folder within your Dropbox.

How do I find all the files under a directory whose file and folder names are greater than 250 characters?

(Note: the "Check bad files" tool on that page doesn't find them either.)

Update: there are two suggestions so far, one using powershell that ironically, died when a filename grew too large, the other using cygwin's find and xargs, which may work, but is still running (several minutes later.)

I did solve my immediate problem.

In an emacs shell window, I ran a very simple find

$ find . -type f -print >> ../files.log

Then I opened that in emacs and typed m-x list-matching-lines ^ ESC 230 . RETURN

Which displays lines that match a regular expression, and the regular expression here is that the line contain at least 230 characters, where 230 was just a rough guess for lines that might be problematical. And that showed me two files that were too long.

For about 20,000 files that regular expression filter turned out to be almost instantaneous.

share|improve this question

If you happen to have cygwin installed, I think this should work:

find /cygdrive/c/Users/username/Dropbox -type f -print0 | xargs -0 -I {} bash -c 'if [[ $(echo -n "{}" | wc -c) -gt "269" ]]; then echo "{}"; fi'

Sorry that I don't know of the native way of doing the same.

share|improve this answer
I have cygwin, so thanks. I think it might be nice to know if there is a standard windows way to do this, since apparently windows lets you make these files but doesn't let you easily discover them! – Jerry Sep 20 '13 at 6:08
I tried that, and in fact, several minutes later it is still working (taskmgr confirms xargs is running quote a bit), and so far it has spit out $ find . -type f -print0 | xargs -0 -I {} bash -c 'if [[ $(echo -n "{}" | wc -c) -gt "255" ]]; then echo "{}"; fi' bash: -c: line 0: unexpected EOF while looking for matching )' bash: -c: line 1: unexpected token ÿ' in conditional command bash: -c: line 1: syntax error: unexpected end of file – Jerry Sep 20 '13 at 6:28
Another update. I suspect the find from cygwin would have worked fine. It turned out the find in my PATH was coming from the native GIT installation. – Jerry Sep 20 '13 at 7:17

Open up the Powershell console: Get-ChildItem -r * |? {$_.GetType().Name -match "File" } |? {$_.fullname.length -ge 260} |%{$_.fullname}

Credit to @rerun who posted this in Stack Overflow.

share|improve this answer
Interesting, thank you. I'll try this as well. – Jerry Sep 20 '13 at 6:09
Ironically, the above resulted in Get-ChildItem : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters. At line:1 char:1 + Get-ChildItem -r * |? {$_.GetType().Name -match "File" } |? {$_.fullname.length ... + ~~~~~~~~~~~~~~~~~~ + CategoryInfo : ReadError: (C:\Users\jerry\...\blogs\markdown:String) [Get-ChildItem], PathTooLongException + FullyQualifiedErrorId : DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand – Jerry Sep 20 '13 at 6:17

Hmm -- find | xargs | bash - invocation of a single bash process (edit:oops - missed the xargs, sorry, pls ignore the rest of this paragraph :) to count just the length of one line, seems a bit 'process heavy'. There will be as many bash invocations as there are files, could be a lot...

'find | awk' will incur one process on each side (ie:only 2 processes)

Try this (for what should be a much faster result [edit:maybe not so with xargs]):

find . -type f | awk 'length > 259' > longfilename-list.txt

Assumptions: may be OS dependant, YMMV - find will default to printing the match, so no -print0 needed. - 'print $0' (the matching line) is default action in awk, so no {print} is required after the comparison.

share|improve this answer
-print0 is important if the file names could contain newlines. In addition for xargs it is also extremely important for file names containing other white spaces, quotes and backslashes. These all are by default separators and special characters for xargs! ------ Your code with awk is good except for file names containing newlines which is not probably allowed in Windows. ------ The code could be even shorter. . is default. And empty directory name lengths should be checked too: find | awk 'length > 259' – pabouk Dec 4 '13 at 8:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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