App for checking path character count

Discussion in 'Mac Apps and Mac App Store' started by sublevel4, Jun 24, 2016.

  1. sublevel4 macrumors newbie

    Feb 20, 2009
    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.
  2. hughm123 macrumors newbie

    Dec 3, 2014
    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
  3. hughm123 macrumors newbie

    Dec 3, 2014
    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.

Share This Page