Re: Setting working directory
- To: mathgroup at smc.vnet.net
- Subject: [mg41266] Re: Setting working directory
- From: "Peltio" <peltio at twilight.zone>
- Date: Sun, 11 May 2003 03:49:00 -0400 (EDT)
- References: <b9ic3q$pe4$1@smc.vnet.net>
- Reply-to: "Peltio" <peltioNOSP at Miname.com.invalid>
- Sender: owner-wri-mathgroup at wolfram.com
"RazroRog" wrote >How can I change the default >working Directory and file search Path as Global Options that gets loaded >each time I run Mathematica? Add the instruction to your init.m file. You might want to add the following lines, for example $MyWorkingDir= (*your working directory path*) $Path=AppendTo[$Path, $MyWorkingDir] SetDirectory[$MyWorkingDir] You might also want to add other global variables declarations in order to simplify switching from one directory to another one without having to retype the full path explicitly. For example, these variables point to a temporary directory and to a directory used to store the data. $DataDir=ToFileName[{$TopDirectory, "AddOns", "Data"}]; $TempDir=ToFileName[{$TopDirectory, "AddOns", "ExtraPackages","Temp"}]; Adding $DataDir to the path can be very useful: you put the data you want to work with into that dir (thus avoiding to clutter your working directory with tons of tables, for examples) and Mathematica will find it for you. The use of such variables comes handy when you work with Mathematica on different OSes: once you included them with the correct syntax in the init.m for each OS you can refer to them in a consistent way across the different platforms (i.e. no more //, ~, . ). Moreover, based on a suggestion posted in this group, it is also possible to define a variable that gives back the directory of the notebbok currently evaluated: $ThisNBDirectory := DirectoryName[ ToFileName[ "FileName" /. NotebookInformation[EvaluationNotebook[]] ] ] In this way you can act on data that is in the directory of the notebbok by simply setting SetDirectory[$ThisNBDirectory] (it's useful when you want to see what a package does without having to place it in a directory in your path). Okay, I think I've said too much. Hope that helps, anyway, Peltio invalid address in reply-to, demunging required to mail me