faceoftheearth
Programmer
I've set up a Perl script that essentially makes VLC stream an mms stream into a file. I have it set up so that VLC saves the file as month-day-year. So today the filename is 5-17-2007. What I want to do is to check if a file already exists for today and if so to append a number to the save name. So it would check if 5-17-2007 exists and if so would save the file as 5-17-2007-1. If it finds that 5-17-2007-1 exists, I want it to create 5-17-2007-2 etc.
As of now I can check if the current date already has a file using a simple if(-e $inpath.$date). If it finds that it assigns a random integer to the end of the filename. This works better, but there's still a chance of overwriting a file and it is just generally a horrible idea.
My tactic was to be (psuedo code)
if(-e $inpath.$date.number)
{
get filename, chop number off end, increment number, create new filename
}
How can I do that?
Thanks
As of now I can check if the current date already has a file using a simple if(-e $inpath.$date). If it finds that it assigns a random integer to the end of the filename. This works better, but there's still a chance of overwriting a file and it is just generally a horrible idea.
My tactic was to be (psuedo code)
if(-e $inpath.$date.number)
{
get filename, chop number off end, increment number, create new filename
}
How can I do that?
Thanks