3

I need to move a large volume to a new raid server that's PC formatted. However I have a couple paths and filenames that are interrupting this process.

I would just like to know how to use the terminal to:

  1. Locate the targeted external drive
  2. Then search that drive for paths/files that are over 130 characters

Can anyone help?

I know how to search for long paths find " . -type f -name '?????...*' ", just not sure how to target my external drive.

3

The external drive is mounted under /Volumes, run ls /Volumes to see the exact name.

Afterwards you can use

find /Volumes/NAME-FROM-ABOVE -print |
    while read line; do [[ ${#line} -gt 130 ]] && echo $line; done

to list all files where path and filename combined are longer than 130 characters.

PS: This will not work for file/path names containing new lines and similar stuff (which usually isn't a problem) PPS: If your volume name contains spaces you need to wrap it in "" -> find "/Volumes/LaCie - BRYT" -print ...

  • So my volume I'm wanting to target is 'LaCie - BRYT' but I think the name of the volume is messing with my print. I'm getting a return of "unknown primary or operator". – handpaintedstudio Jul 17 '17 at 21:05
  • See edit. But go with Allan's solution for the whole thing, it's much nicer, slightly faster and will also work for edge cases like file names with new line characters – nohillside Jul 17 '17 at 21:07
  • Ok got it! I was able to run find "/Volumes/LaCie - BYRT" -print | while read line; do [[ ${#line} -gt 130 ]] && echo $line; done Which printed a lot. Thank you guys!! – handpaintedstudio Jul 17 '17 at 21:29
4

The following command will print out all files that have more than 130 characters

find -E . -type f -regex '.*[^/]{130}'

The Terminal (bash) command to list the disks attached to the system is diskutil. The command diskutil list will output all disks - just select the identifier that matches your external device.

For example:

/dev/disk3 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk3
   1:                        EFI EFI                     209.7 MB   disk3s1
   2:                  Apple_HFS FreeAgent Go            499.8 GB   disk3s2
/dev/disk4 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk4
   1:                        EFI EFI                     209.7 MB   disk4s1
   2:                  Apple_HFS My Passport for Mac     999.8 GB   disk4s2

disk0, disk1, and disk2 are in a CoreStorage volume. disk3 and disk4 are my external drivers

To access the drive (assuming it's mounted), look in the /Volumes directory for the appropriate mount point.

Assuming you wanted to search "My Passport for Mac" you would enter the command:

find -E /Volumes/My\ Passport\ for\ Mac/ -type f -regex '.*[^/]{130}'
  • 1
    Standard find doesn't support -regextype, unfortunately. – nohillside Jul 17 '17 at 20:43
  • @patrix - you're right...I'm on ssh session to a different machine so of course, when I tested, it worked. Duh... – Allan Jul 17 '17 at 20:44
  • But -E works -> find -E . -type f -regex '.*[^/]{130}' :-) – nohillside Jul 17 '17 at 20:45
  • 1
    I was just reading the man page on -E when your comment came in. Unfortunately, I don't have any files that long to really test it out with. Thx! – Allan Jul 17 '17 at 20:48
  • So if my identifier is "disk3s2" how would I write it (sorry very noob). – handpaintedstudio Jul 17 '17 at 20:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .