2
$\begingroup$

I'm trying to use Mathematica to analyse data that's saved (by my colleagues) to https://drive.google.com/ but I have run into a problem with the full pathname of files exceeding Window's limit of 239 characters. Can anyone help me overcome this problem? I cannot solve the problem by asking for the files to be saved elsewhere, or to a more sensible folder structure; I have to deal with what already exists on my company's G-drive.

With Google Drive for Desktop installed on my PC I can access most of the files that are saved to the G-drive's rather deep folder structure. Most files can be found by ...

SetDirectory["G:\\.shortcut-targets-by-id\\1IkH9DDQjZmXWWeE2useGtzj6LCWh02nY\\\filesToAnalyze"];
dirs = Select[FileNames[], DirectoryQ[#] &];
allCSVFiles = FileNames["*.csv", dirs, Infinity];

Unfortunately some of the files are deeply buried and have long filenames so the full pathlength exceeds Window's character limit and I get the Mathematica error "General::dirdep: Cannot get deeper in directory tree: G:\.shortcut-targets-by-id\1IkH9DDQjZmXWWeE2useGtzj6LCWh02nY\filesToAnalyze\\... \<stuff deleted\>"

I've been able to use the extended-length path syntax ideas (i.e., \\?\) described here to open files that have long pathnames, but I can't work out how to use FileNames[] to find them. I also can't see how I can use the short path names solution in that article to make FileNames work.

There is a description by Microsoft (here) about changing the registry to remove the 239 character limit - and I've done that - but you also need to add a longPathAware element to the "application manifest". Has anyone succeeded in doing this for Mathematica? If so, can you gve me some guidance on what to do, for example where do I find the manifest .xml file?

$\endgroup$
2
  • $\begingroup$ Is accessing Google Drive directly an alternative? See here $\endgroup$
    – rhermans
    Commented Jul 4, 2022 at 14:13
  • $\begingroup$ Since you are on Windows, does subst command helps? $\endgroup$
    – Ben Izd
    Commented Jul 4, 2022 at 14:31

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.