Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.


#368 Backup filenames

core (195)

It's awesome that jedit keeps many backup copies of a file, however I feel there's a fundamental flaw with the backup filename convention that jedit uses.

I, for example, have nominated for Jedit to keep a backup of up to 1000 copies of a file. This is great! However why does jedit create backup files like this:


where a.txt1 is the earliest and a.txt3 is the latest backup of a.txt

If say I need to restore the last successful edit of a file I need to find the highest number jedit has allocated to that particular file. This is easy if I was working on one file in one directory. But when I've been working on 1000 files in one directory it becomes really unwieldy. Like I have to go through every single file, work out the highest number for each file which is really time-consuming and therefore annoying, especially seeing 11 is less than 2 as far as the filesystem is concerned.

I suggest a basic change to the file-naming strategy:

If jedit makes a backup of a.txt on a save and it hasn't backed up a.txt before then it simply backs it up as a.txt. The next time jedit makes a backup of the same file it should rename the already backed up a.txt to a.txt1 and then save the backup of a.txt as a.txt. The next time I save a.txt it should rename the last backup of a.txt to a.txt2 before backing up as a.txt again.

That way if I need to "get back" the last copy of everything I've edited in a directory I can simply copy *.txt or whatever the normal extension is out of the backup directory and, viola, I have every latest copy of every file that jedit managed to backup successfully.


ps: wicked editor guys - I've been coding with it for years - you won't catch me using an IDE no sir.


  • First, I don't understand. You suggest to name the most recent backup of "a.txt" as "a.txt" - which is the name of the original file?
    Second, I just checked the code that does the backup - and the indices in the file extension actually go down (e.g. a.txt1 is newer than a.txt2) - so if you look for the most recent backup, that will always be the one with index 1. Of course, to do this, the backup procedure goes over all older backups and renames them, to increase the index of the backup... I guess it was done exactly to resolve the issue you raise. (Otherwise I cannot understand why jEdit would do so much redundant file-renaming work)

    Let me know if this is still a problem - my understanding is that there is no issue.

    • status: open --> pending
  • Tristen

    Yeah :P sorry, it seems I was mistaken...

    to address your second remark, er, first:

    Wow that's strange, I coulda sworn it was simply writing the latest backup of a file as the greatest number, but obviously not:

    ls -l --time-style=full-iso
    total 24
    -rw-r--r-- 1 tristen tristen 7 2010-08-08 02:50:57.364630394 +1000 a.txt1
    -rw-r--r-- 1 tristen tristen 7 2010-08-08 02:49:41.576635846 +1000 a.txt2
    -rw-r--r-- 1 tristen tristen 6 2010-08-08 02:49:39.956175733 +1000 a.txt3
    -rw-r--r-- 1 tristen tristen 5 2010-08-08 02:49:38.020233963 +1000 a.txt4
    -rw-r--r-- 1 tristen tristen 4 2010-08-08 02:49:35.849138131 +1000 a.txt5
    -rw-r--r-- 1 tristen tristen 3 2010-08-08 02:49:33.084185420 +1000 a.txt6

    So yeah, the latest backup is "a.txt1", not "a.txt6" - soz!

    I dunno why I had it in my mind that the opposite was true, but hey maybe from an earlier version or something? Doesn't matter.

    Yep, I agree this method is pretty redundant, like if I have 1000 backup copies of a file then jedit will be renaming 1000 files (which isn't that unrealistic for me because I subconsciously ctrl-s every other millisecond or so :)

    Also noteworthy: I have jedit backup to a completely different directory than the directory I'm working in - so jedit happily recreates the directory structure of the files I'm working on under the directory I nominated to backup into. Which is an awesome feature btw. That's why I'd like the latest backup copy of the original filename written there as a.txt without a number. But I suppose if it's commonplace to have jedit backup into the same directory you're working in, then it's not really a valid requirement 'cos the file has already been saved there.

    I didn't even realise you could set jedit to backup into the same directory as the file you're editing.

    Anyway, to cut a long story short: I can live with knowing that a.txt1 is my latest version!

    Cheers and sorry for the confusion!

  • Tristen

    • status: pending --> open
  • Closing item as there's no issue.

    • status: open --> closed-invalid