Shrinking file size to the new smaller contents on exit



  • I have a number of bash and perl scripts that depend on the size of a file after an editing session. What I’ve seen from npp (Notepad++), is that if you just close the editor, it will write the file, but it doesn’t shrink the size of the file to the new smaller size.

    If, however, you hit ^-S to save before you exit, it will shrink the file size to a new smaller size.

    Is there any way to change the default to the latter operation?

    TIA,

    Lee



  • Hello Lee,

    I guess you are talking about the session snapshot and periodic backup functionality.
    Can be found under settings->preferences->backup.
    But this would mean, that npp hasn’t really updated the file itself instead of the backup it has created.
    When disabling the mentioned session… you will be asked to save modified files before npp shuts down.
    Or did I miss something?

    Cheers
    Claudia



  • It is updating the file, in that the content is gone on next edit, or run (if a script), but the file size does not change!



  • I still think this is related to the session snapshot and periodic backup functionality.
    A few questions

    I have a number of bash and perl scripts that depend on the size of a file after an editing session

    What means editing session? You edited the file or the bash/perl scripts?

    What I’ve seen from npp (Notepad++), is that if you just close the editor, it will write the file, but it doesn’t shrink the size of the file to the new smaller size.

    As said, this sounds like snapshot and periodic backup functionality is ative, because otherwise
    npp would ask you whether to save any of the modified files. Is this the case? Does npp
    ask you to save the files if you close the editor?

    It is updating the file, in that the content is gone on next edit, or run (if a script), but the file size does not change!

    How do you check that the file size didn’t change? Did you try to open that file with a different
    editor, preferable a hex editor? Is it still empty?

    Cheers
    Claudia


Log in to reply