Repository: spyder-ide/spyder

Issue:
Date/time-based filename (when saving) for figures on Plots pane
Generate a date/time-based filename (so we don't need to rename each picture we want to save if saving multiple figures). Look at the picture below to see how Snip & Sketch generates a date/time-based file name:

![Annotation 2019-11-27 105138](https://user-images.githubusercontent.com/57544001/69744084-844b5d00-110d-11ea-9451-af2e2338e3f1.jpg)



Discussion:
Thoughts on this @jnsebgosselin ?
> 
> Thoughts on this @jnsebgosselin ?

Its a good idea to add the date.

From the screenshot above, it seems that the first 6 characters of a uuid is also added at the end to ensure uniqueness of the filename. Do you think we should do that also?
The last 6 characters represent the time in the format "hhmmss", which is great when one is saving a series of charts on the same day.
> 
> 
> The last 6 characters represent the time in the format "hhmmss", which is great when one is saving a series of charts on the same day.

Ah I see! ahah Thanks for the clarification.

I can implement that if the feature is accepted.
>I can implement that if the feature is accepted.

I like it :-) @ccordoba12 ?

Sure. it'd be nice to have in Spyder 5.
Does future means "Do it against master branch" or it can be done against the 4.x branch?
Hmmm well, if you want to work on it soon, then 4.x is fine I guess. 

---

Side note:
We are now using zenhub to organize the workflow and in that workflow milestones are sprints, releases (a zenhub thing) groups what we used as milestones and we added this as labels as well for non zenhub users.
> Hmmm well, if you want to work on it soon, then 4.x is fine I guess.

Agreed.

Resolving patch:
diff --git a/spyder/plugins/plots/widgets/figurebrowser.py b/spyder/plugins/plots/widgets/figurebrowser.py
--- a/spyder/plugins/plots/widgets/figurebrowser.py
+++ b/spyder/plugins/plots/widgets/figurebrowser.py
@@ -12,6 +12,7 @@
 
 # ---- Standard library imports
 from __future__ import division
+import datetime
 import os.path as osp
 import sys
 
@@ -58,11 +59,11 @@ def get_unique_figname(dirname, root, ext):
     in "dirname".
     """
     i = 1
-    figname = root + '_%d' % i + ext
+    figname = '{}{}'.format(root, ext)
     while True:
         if osp.exists(osp.join(dirname, figname)):
+            figname = '{} ({}){}'.format(root, i, ext)
             i += 1
-            figname = root + '_%d' % i + ext
         else:
             return osp.join(dirname, figname)
 
@@ -741,6 +742,8 @@ def save_all_figures_as(self):
     def save_all_figures_todir(self, dirname):
         """Save all figure in dirname."""
         fignames = []
+        figname_root = ('Figure ' +
+                        datetime.datetime.now().strftime('%Y-%m-%d %H%M%S'))
         for thumbnail in self._thumbnails:
             fig = thumbnail.canvas.fig
             fmt = thumbnail.canvas.fmt
@@ -748,7 +751,7 @@ def save_all_figures_todir(self, dirname):
                     'image/jpeg': '.jpg',
                     'image/svg+xml': '.svg'}[fmt]
 
-            figname = get_unique_figname(dirname, 'Figure', fext)
+            figname = get_unique_figname(dirname, figname_root, fext)
             save_figure_tofile(fig, fmt, figname)
             fignames.append(figname)
         return fignames
@@ -767,7 +770,10 @@ def save_figure_as(self, fig, fmt):
             'image/svg+xml': ('.svg', 'SVG (*.svg);;PNG (*.png)')}[fmt]
 
         save_dir = CONF.get('plots', 'save_dir', getcwd_or_home())
-        figname = get_unique_figname(save_dir, 'Figure', fext)
+        figname = get_unique_figname(
+            save_dir,
+            'Figure ' + datetime.datetime.now().strftime('%Y-%m-%d %H%M%S'),
+            fext)
 
         self.redirect_stdio.emit(False)
         fname, fext = getsavefilename(


Test patch: