Tool to identify all filepaths/filenames exceeding Windows' allowed length?
I have a folder containing several nested subfolders.
The parent folder is 1.2GB, and contains nearly 3,000 mainly screenshot image files.
My Mac doesn't have a problem with the long filepaths/names obvs, but I now need to share these files with a very large UK Authority running Windows (not sure which version, as my Q has fallen on deaf ears so far...)
I think the only method I will be allowed to share the files by is OneDrive/Sharepoint - the Authority is restricted from using any other Cloud sharing method.
Due to the nesting (which has to stay) many of the filenames/paths are too long, and One Drive is repeatedly rejecting over 1,200 of them without syncing.
Pop-up error box only shows one offending filepath, helpfully doesn't offer a list of 'non-compliant' files.
Is there a quick way of identifying and grouping the offending filenames/filepath names together so as I can rename them?
I don't want to batch rename them in case that alters the meaning I've chosen for the individual file names, which are important.
Over 95% of the files are image-only files and evidence in an employee fraud investigation. Each filename is important as it gives context to the image, hence me not wanting to use a batch tool to change the names to something shorter but unhelpful.
I don't mind going through them one by one, but need to know which are the 'offending' filenames/filepaths if I'm to do so.
It may be that I can also nest the folders slightly differently if I know which ones are causing the problems, as that may reduce the filepath length.
Ideally I'm seeking a canny bit of software similar to MassReplaceIt (which I've already used to find and replace 'illegal characters' in the filenames) but can use terminal command if no software exists.
Thanks!
Solution 1:
Assuming somewhat sane file/folder names
find TOPDIR | while read line; do [[ ${#line} -gt 1200 ]] && echo $line; done
will print all paths/files where the combined length exceeds 1200 characters. This should allow to spot troublesome folder names and rename them accordingly.