Jump to content

Incrementing file number if 'file(x)' exists


gijew

Recommended Posts

I've been working on this all morning and I finally got myself to a point where I'm ready to start doing hello world scripts again :)

 

What should have been easy has turned into a chore. The basics are I'm uploading files to a directory. I want to check if the file exists in the directory. If it does, I want to see what the final count is and increment to the next one. That's where I've been working on my regex. I'm not strong but I have an okay understanding.

 

// SAMPLE

test.txt

test (1).txt

test (2).txt

 

// REGEX

([a-zA-Z0-9]+)\s\(([0-9]+)\).([a-z]+)

 

That will match test (1).txt and test(2).txt. I need incorporate the "test.txt" without the auto_increment. How can I do that?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.