Community
    • Login

    How to save new (!) documents always in D:\data\ ? (And not in most recent directory)

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    10 Posts 4 Posters 304 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Claudia SvensonC
      Claudia Svenson
      last edited by

      Assume I create a new (!) file and write something into it.

      Then I want to save it into the directory D:\data
      So I click on menu
      File—>Save as…
      and the windows 10 file selection dialog shows me either the most recently used directory are a completely arbitrary directory.

      I have to navigate with a dozend of clicks to the desired target directory
      D:\data
      very uncomfortable and annoying.

      How can I tell NP++ to ALWAYS offer me as default save directory D:\data\

      Of course if I load an existing file and edit something then the source directory should be offered at first.

      Alan KilbornA CoisesC 2 Replies Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @Claudia Svenson
        last edited by Alan Kilborn

        @Claudia-Svenson

        You can pick only ONE:

        e8b42b13-dd3e-4a98-8c9c-2bf5da82823c-image.png

        If you pick the bottom one, that’s where you’d add your D:\data


        I have to navigate with a dozend of clicks to the desired target directory D:\data

        Or, just type into the box the SaveAs dialog is offering you: d:\data\myfile.txt

        Claudia SvensonC 1 Reply Last reply Reply Quote 2
        • guy038G
          guy038
          last edited by guy038

          Hello, @claudia-svenson, @alan-kilborn and All,

          @alan-kilborn,the classical solution that you proposed as well as the work-around to simply write D:\Data\file.txt are correct.

          However, choosing a specific directory to follow ( third choice ) will apply to, both, saved or unsaved files !


          To my mind, @claudia-svenson would like this kind of dialog in Preferences... > Default Directory > Default Directory (Open/Save) :

          
              (•) Follow current document
          
              (•) Remember last used directory
          
              (•) Directory for Saved files  with a FIRST field and the ... button
          
              (•) Directory for Unsaved files  with A SECOND field and the ... button
          

          Personally, I would like this new behavior. So the @claudia-svenson’s D:\Data directory would look as a folder containing various saved notes and usual material that you could refer to, at any moment !

          Of course, if you do not choose the options 1 or 2, the 3 option would be mandatory and if the 4 option was empty, it would use, by default, the directory of the 3 optiuon.


          But, may be it’s not the true need of @claudia-svenson or my reasoning is perhaps very week in that matter ?

          Best Regards,

          guy038

          1 Reply Last reply Reply Quote 1
          • Claudia SvensonC
            Claudia Svenson @Alan Kilborn
            last edited by

            @Alan-Kilborn

            If I pick the 3rd radio button then ALL files are saved into this directory.
            But I want to use this directory only for NEW files.
            For loaded, existing files the “follow current directory” rule should be taken.

            Your suggestion typing in manually “d:\data\myfile.txt”
            is almost as uncomfortable as clicking through the dir tree in folder selection dialog. So its not a solution.

            So what I need here is a split rule in “Default Directory” section:

            Default Save file directory (for existing, loaded files):
            …
            …
            …
            Default Save file directory (for new files):
            …

            Can this option be added in the next release?

            Alan KilbornA 1 Reply Last reply Reply Quote 0
            • Alan KilbornA
              Alan Kilborn @Claudia Svenson
              last edited by Alan Kilborn

              @Claudia-Svenson said:

              I want to use this directory only for NEW files.
              For loaded, existing files the “follow current directory” rule should be taken.

              Leave the setting at Follow current document.
              Install the Take Notes plugin and use its Create New Note feature, rather than Ctrl+n (or, suggested: configure Take Notes to override).
              Of course, you must use the Take Notes 's Option… menu to configure your D:\data folder (along with other desired settings).

              1 Reply Last reply Reply Quote 1
              • guy038G
                guy038
                last edited by

                Hello, @alan-kilborn and All,

                Alan, why do you think that the @claudia-svenson’s request, and my post which described the same feature, are NOT really interesting and pertinent, despite of various work-arounds ?

                Best Regards,

                guy038

                Alan KilbornA 1 Reply Last reply Reply Quote 0
                • guy038G
                  guy038
                  last edited by guy038

                  Hello, @alan-kilborn and All,

                  Well, I 've just realized that my description of the behavior of the possible new Default Directory (Open/Save) section, in Preferences, is a bit erroneous !

                  Indeed, whatever the option 1, 2 or 3 chosen for saved files, two cases would be possible :

                  • If NO directory is shown, for the 4 new option, the unsaved files would respect the option chosen for saved files ( present N++ behavior )

                  • If a directory is shown, for the 4 new option, the unsaved files would be saved in that specific directory, only

                  BR

                  guy038

                  1 Reply Last reply Reply Quote 0
                  • Alan KilbornA
                    Alan Kilborn @guy038
                    last edited by

                    @guy038 said:

                    why do you think that the @claudia-svenson’s request, and my post which described the same feature, are NOT really interesting and pertinent

                    Did I say that?
                    No, but OK, it isn’t really interesting to me (maybe others?).

                    I do think that Take Notes plugin solves the problem very nicely.

                    …two cases would be possible…if NO directory…if a directory…

                    This kind of thing pretty much makes it impossible for the casual user to get their head around the functionality, without consulting the manual.

                    1 Reply Last reply Reply Quote 1
                    • CoisesC
                      Coises @Claudia Svenson
                      last edited by

                      @Claudia-Svenson

                      There is one thing I haven’t seen mentioned here yet. It’s the way I have Notepad++ set up:

                      Select Follow current document as the default directory. In the shortcut you use to start Notepad++, set the directory you want to use when there is no current document as the Start in directory.

                      In this set-up, when an existing document is open, the Open and Save As commands will begin in the folder containing that document. If you switch to an as-yet-unsaved file, Open, Save and Save As will begin in the folder containing the last existing document you viewed in that session. But if you start Notepad++ without opening any existing documents, Open, Save and Save As will begin in the folder you set as the working directory.

                      It’s not exactly what you requested, but perhaps close enough to reduce aggravation.

                      1 Reply Last reply Reply Quote 5
                      • Alan KilbornA
                        Alan Kilborn
                        last edited by Alan Kilborn

                        The following is TL;DR…

                        A bit ago, I had a need for a “directory chooser” standard dialog to appear in one of my PythonScripts. I shared this need with the guru of all things Python (@Ekopalypse , although he will shrug off that moniker) and he graciously pursued adding code to support that in his Little Dialog Wrapper project.

                        Because a directory-chooser is really just a specialized “file open” standard dialog, Eko also provided that capability – great. So now the library had file-open and dir-chooser capability. But…the glaring omission to complete the set was a “file save” standard dialog. Well…of course I nudged Eko to write that part as well, but I think he simply saw no need for it and thus didn’t do it. And so of course I said I’d do it.

                        But much time passed, and I didn’t do it, because I didn’t exactly have a burning need. I already had some script code I’d developed for file-save based on some ancient code called EasyDialogs. And wow, checking out that link right now, it is really ancient (circa 2007)! This approach worked, but the type of standard dialogs generated by EasyDialogs are really “old school”.

                        So then along comes this thread (the one we’re talking in right now). The OP’s need is one that can be easily scripted…IF a nice file-save dialog could be generated.

                        So, I got on the proverbial horse and added the file-save dialog code to Eko’s library (in the end not a big effort, since the earlier code provided a lot of inheritable stuff). It’s been ACCEPTED and now the library offers the full complement of file-open, file-save, and directory-chooser standard dialogs.


                        Ok, so here’s a (PS3) script called FileSaveReplacement.py that meets the need proposed at the start of this thread. The script is run (somewhat obviously from its name) when you’d normally save a file (i.e., hint reassign Ctrl+s to run this script). If the tab being saved exists as a file in the file system, it’s simply saved as usual. But if the tab has never been saved, a file-save dialog appears and it is based in a fixed directory (as specified in the script by the dir_for_never_saved_files variable).

                        # -*- coding: utf-8 -*-
                        
                        #########################################
                        #
                        #  FileSaveReplacement (FSR)
                        #
                        #########################################
                        
                        # note:
                        #  This script was developed and tested under Python3 64-bit on unicode (non-ANSI) encoded data.
                        #  It may work as-is using Python2 and/or ANSI-encoded data and/or 32-bits, but that would be incidental.
                        
                        # references:
                        #  https://community.notepad-plus-plus.org/topic/26900/how-to-save-new-documents-always-in-d-data-and-not-in-most-recent-directory
                        #  for newbie info on PythonScripts, see https://community.notepad-plus-plus.org/topic/23039/faq-desk-how-to-install-and-run-a-script-in-pythonscript
                        #  for info on WinDialog (aka Little Dialog Wrapper), see
                        #   https://github.com/Ekopalypse/NppPythonScripts/tree/master/helper/WinDialog
                        #   https://community.notepad-plus-plus.org/topic/24389
                        
                        #-------------------------------------------------------------------------------
                        
                        from Npp import *
                        import os
                        from WinDialog import *  # "Little Dialog Wrapper"
                        from WinDialog.com_dialogs import FOS
                        
                        #-------------------------------------------------------------------------------
                        
                        class FSR(object):
                        
                            def __init__(self):
                        
                                # config:
                                dir_for_never_saved_files = r'd:\data'
                                ext_for_never_saved_files = '.txt'  # make this an empty string if the desire is to have no extension
                        
                                curr_filename = notepad.getCurrentFilename()
                                if os.path.isfile(curr_filename) and ('\\' in curr_filename or '/' in curr_filename):
                                    notepad.menuCommand(MENUCOMMAND.FILE_SAVE)
                                else:
                                    save_dlg = FileSaveDialog()
                                    save_dlg.setFolder(dir_for_never_saved_files)
                                    if '.' not in curr_filename: curr_filename += ext_for_never_saved_files
                                    save_dlg.setFileName(curr_filename)
                                    save_dlg.setFileTypes([['All files', '*.*'], ['Text Files', '*.txt']])
                                    save_options = save_dlg.getOptions()
                                    save_options |= FOS.OVERWRITEPROMPT
                                    save_dlg.setOptions(save_options)
                                    result = save_dlg.show()
                                    if len(result) > 0: notepad.saveAs(result[0])
                        
                        #-------------------------------------------------------------------------------
                        
                        if __name__ == '__main__': FSR()
                        
                        1 Reply Last reply Reply Quote 2
                        • Alan KilbornA Alan Kilborn referenced this topic on
                        • First post
                          Last post
                        The Community of users of the Notepad++ text editor.
                        Powered by NodeBB | Contributors