I have a "board"/"dating"-service where my users can send messages to each others(school-project).
I store all the messages in a "Users/$username/messages/inbox/"-folder as .txt files named 1.txt, 2.txt, 3.txt -----> 100.txt.
I would like to limit the number of messages to 100, and I guess I could manage to program that by myself(I hope), but my big problem is this:
If a user wants to erase say message nr#46(46.txt), how can i manage to rename message 47-100(47.txt --- 100.txt) to have a new name like 46-100(46.txt --- 99.txt) ??
Do I have to move them to a temp-dir, rename all the files in a loop and erase the contents of my "inbox"-dir and put the files back in there, or does anyone have a good solution ???