Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sublevel4

macrumors newbie
Original poster
Feb 20, 2009
20
0
I need a osX app that will search a shared drive for files with a file path over a certain file length. The drive is a network share that i need to search. I need it to tell me what files are longer than 256 characters and where those files are. Does anyone here have any recommendations?

Thank you.
 
You don't say if you want to call this from a script or other app, but one option is to open a terminal (Applications->Utilities->Terminal) and then type:

find /Volumes/whatever -print | sort | perl -e 'while(<>) { print if(length > 257) }'

You may have to adjust "257" by one if my math is off - this command includes the name plus the trailing newline character, hence 256+1=257.

If you want the results in a file, add "> filename.txt" to the end:

find /Volumes/whatever -print | sort | perl -e 'while(<>) { print if(length > 257) }' > results.txt
 
  • Like
Reactions: sublevel4
Alternate single command to use in Terminal, without needing perl:

find -E /Volumes/whatever -regex '.{256,}'
or: find -E /Volumes/whatever -regex '.{256,}' | sort

"man find" for more explanation and other options to find. For the pattern ('.{256,}'), "." means any character, and "{256,}" means "256 or more repeats". This results in any path with 256 characters or more.
 
  • Like
Reactions: sublevel4
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.