Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Bare Bones Backup Button

  • To: mathgroup at smc.vnet.net
  • Subject: [mg77555] Re: [mg77536] Bare Bones Backup Button
  • From: DrMajorBob <drmajorbob at bigfoot.com>
  • Date: Wed, 13 Jun 2007 07:20:15 -0400 (EDT)
  • Organization: Deep Space Corps of Engineers
  • References: <200706080938.FAA03696@smc.vnet.net> <200706090943.FAA17991@smc.vnet.net> <acbec1a40706090337i64852d8cja3b1b942c7b29fec@mail.gmail.com> <06D466A7-0D44-40DB-ACB5-F488E9D2B08B@mimuw.edu.pl> <acbec1a40706090412u7c2da126nf291c7d4628d7c4a@mail.gmail.com> <14694989.1181527374589.JavaMail.root@m35> <200706110827.EAA21339@smc.vnet.net> <3306125.1181629909918.JavaMail.root@m35>
  • Reply-to: drmajorbob at bigfoot.com

That doesn't work in Windows ($HomeDirectory is read-only, among other  
things), but this does:

CreatePalette[{Button["Bare Bones Backup",
     Module[{filename, thisnb = InputNotebook[]},
      If[thisnb =!= $Failed,
       CreateDirectory[
        ToFileName[{$UserBaseDirectory, "MathBackups"}]];
       filename =
        StringJoin[
         StringReplace[(WindowTitle /. AbsoluteOptions[thisnb]),
          s_ ~~ ".nb" -> s], "_",
         StringJoin[ToString /@ Round /@ Rest[Date[]]], ".nb"];
       Export[
        ToFileName[{$UserBaseDirectory, "MathBackups"}, filename],
        DeleteCases[NotebookGet[thisnb], Cell[_, "Output", ___],
         Infinity]]]]]}];

Execute the code, and it creates the palette. Now... and this is dumb...  
grab the palette and move it. Then close it, and Mathematica asks if you 
want to save the palette.

If you DON'T move it, there's no way (I can find) to save the palette.  
Using Selwyn's CreateDocument version, even moving the palette doesn't  
work.

I discovered the needed changes by trial and error; the documentation was  
no help at all. There are dozens of palette and notebook creation  
examples, but none of them (that I could find) show how to save the result.

Bobby

On Tue, 12 Jun 2007 00:23:53 -0500, Selwyn Hollis <sh2.7183 at earthlink.net>  
wrote:

> This is something I've wanted for years. Click the button, and a copy
> of the current InputNotebook -- with output cells deleted -- is
> Exported into a backup folder in your $HomeDirectory.
>
> CreateDocument[PaletteNotebook[
> Button["Bare Bones Backup",
>     Module[{filename, thisnb = InputNotebook[]},
>      If[thisnb =!= $Failed,
>       CreateDirectory[ToFileName[{$HomeDirectory, "MathBackups"}]];
>       filename =  StringJoin[
>         StringReplace[(WindowTitle /. AbsoluteOptions[thisnb]),
>          s_ ~~ ".nb" -> s], "_",
>           StringJoin[ToString /@ Round /@ Rest[Date[]]], ".nb"];
>       Export[ToFileName[{$HomeDirectory, "MathBackups"}, filename],
>        DeleteCases[NotebookGet[thisnb], Cell[_, "Output", ___],
> Infinity]]
>       ] ] ] ] ]
>
> (Button is new to 6, but the function inside Button should work fine
> in 5.2.)
>
> I've got a version of this that runs automatically every 15 minutes
> (you can change the interval, of course). Anyone who's interested
> should let me know.
>
> Selwyn Hollis
>
>



-- =

DrMajorBob at bigfoot.com


  • Prev by Date: Problem with Documentation Center in Mathematica 6 under Linux
  • Next by Date: Re: Normally Distributed Random Matrix
  • Previous by thread: Re: Bare Bones Backup Button
  • Next by thread: Re: Bare Bones Backup Button