dcsimg
Results 1 to 3 of 3

Thread: [RESOLVED] Auto-increment file name when renaming collision occurs

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2011
    Location
    Palm Coast, FL
    Posts
    281

    Resolved [RESOLVED] Auto-increment file name when renaming collision occurs

    Windows File Explorer has a feature when renaming a file where if the new file name is already taken by a file in the same folder, a new name of this form is suggested: "filename (1).ext". If a file with this name is already in use as well, the name "filename (2).ext" is suggested, etc...

    I have coded my own version of this functionality but I'm wondering if there's an API which exposes this functionality?

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2011
    Location
    Palm Coast, FL
    Posts
    281

    Re: Auto-increment file name when renaming collision occurs

    Welp, I just needed to search a little longer...

    Here's a post by Bonnie West which seems to address my question:
    http://www.vbforums.com/showthread.p...=1#post5007755

    In it she discusses two Shell32 APIs which do this:

    PathMakeUniqueName
    https://docs.microsoft.com/en-us/win...makeuniquename

    PathYetAnotherMakeUniqueName
    https://docs.microsoft.com/en-us/win...makeuniquename

    I just need to study these to see what the differences are and which is right for my needs.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2011
    Location
    Palm Coast, FL
    Posts
    281

    Re: [RESOLVED] Auto-increment file name when renaming collision occurs

    I've gotten PathMakeUniqueName to work and the output is what I'm looking for. However, being a Shell32 API, file paths are limited to MAX_PATH in length. So I guess I'm sticking with my own solution.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width