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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.