Monday, June 5, 2017

On Windows 7, how do I find all my files whose filenames are too long

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


https://www.dropbox.com/help/145/en



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.

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...