22
$\begingroup$

Since upgrading to version 10.2.0.0, every time I start the Mathematica front-end it creates a "Wolfram Mathematica" directory under my home directory. (It never seems to put anything in it.) Anybody know how to prevent this behaviour?

$\endgroup$

3 Answers 3

17
$\begingroup$

The "Wolfram Mathematica" directory is created automatically by the front-end and is located in $UserDocumentsDirectory.

It is the default directory to save new documents in and also is on TrustedPath.

The typical location for Linux systems is $HOME/Documents, however it may happen to fall back on $HOME depending on the Xdg user directories setting. This can be changed by

xdg-user-dirs-update --set DOCUMENTS AnyDesiredDirectory
which can prevent the home directory cluttering behavior by using another location.

$\endgroup$
9
  • $\begingroup$ Thanks for the information. I take it this means I can't prevent it? For now I've just put a RemoveDirectory in my init.m $\endgroup$
    – Matt Pusey
    Jul 28, 2015 at 23:31
  • $\begingroup$ @Matt Correct, no way to prevent the creation of that directory, but it is possible to change its location in case the home directory is objectionable. $\endgroup$
    – ilian
    Jul 28, 2015 at 23:37
  • 6
    $\begingroup$ Is this the intended behavior? Or is this faulty behavior? I don't really like a "Wolfram Mathematica" directory under my ~/Documents directory. $\endgroup$ Aug 10, 2015 at 14:32
  • 2
    $\begingroup$ @Andreas It is the intended behavior. Personally I think users should have more control over this -- I would recommend sending feedback to support so they can file a formal suggestion on your behalf. $\endgroup$
    – ilian
    Aug 10, 2015 at 15:47
  • 1
    $\begingroup$ @nix On OS X the location is determined by querying for NSDocumentsDirectory via the NSSystemDirectories API, I am not sure if the operating system allows users to override this in any way. $\endgroup$
    – ilian
    Sep 27, 2015 at 16:43
8
$\begingroup$

Indeed this is annoying. In my ~/.Mathematica/Kernel/init.m I have placed this removal code:

With[{dir = $UserDocumentsDirectory <> "/Wolfram Mathematica"},
  If[DirectoryQ[dir], DeleteDirectory[dir]]
]
$\endgroup$
1
  • 1
    $\begingroup$ Instead of adding "Documents" manually to the path (if necessary), replace $HomeDirectory with $UserDocumentsDirectory. $\endgroup$
    – Janosh
    Aug 24, 2017 at 11:15
1
$\begingroup$

I ended up following the last solution suggested, that is, deleting the folder in the init file. Although it required a few minor modifications for it to work on Windows.

Specifically, Mathematica 11 on Windows 7 creates the folder MyDocuments\Wolfram Mathematica each time it starts, and I couldn't find a user-friendly way to modify or prevent this through the GUI in Preferences, which annoys the hell out of me.

As a simple workaround for Windows, consider editing

C:\ProgramData\Mathematica\Kernel\init.m

adding the command

With[{dir = $UserDocumentsDirectory <> "\\Wolfram Mathematica"}, If[DirectoryQ[dir], DeleteDirectory[dir]]]

to delete it automatically. Note the DOUBLE backslash as folder separator. Alternatively, use FileNameJoin.

Thanks to Darko Veberic for the suggestion.

$\endgroup$
1
  • 1
    $\begingroup$ Instead of double (back-)slashes you could also use FileNameJoin[{$UserDocumentsDirectory, "Wolfram Mathematica"}], which would pick the backslash automatically on Windows. $\endgroup$
    – Ruslan
    Jan 29, 2017 at 12:34

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.