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?
3 Answers
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 AnyDesiredDirectorywhich can prevent the home directory cluttering behavior by using another location.
-
$\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$ 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$– ilianJul 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$– ilianAug 10, 2015 at 15:47
-
1$\begingroup$ @nix On OS X the location is determined by querying for
NSDocumentsDirectory
via theNSSystemDirectories
API, I am not sure if the operating system allows users to override this in any way. $\endgroup$– ilianSep 27, 2015 at 16:43
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]]
]
-
1$\begingroup$ Instead of adding "Documents" manually to the path (if necessary), replace
$HomeDirectory
with$UserDocumentsDirectory
. $\endgroup$– JanoshAug 24, 2017 at 11:15
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.
-
1$\begingroup$ Instead of double (back-)slashes you could also use
FileNameJoin[{$UserDocumentsDirectory, "Wolfram Mathematica"}]
, which would pick the backslash automatically on Windows. $\endgroup$– RuslanJan 29, 2017 at 12:34