Results 1 to 5 of 5
  1. #1
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,185

    Renaming Different Files In Same Folder

    Hi Guy's, I am saving file names (jpg) from the snip tool, renaming them with:



    increment number, Post Code.jpg

    The code here works 100%, however, These files are going into a folder per company name, the stumbling hurdle comes when a company name has got more than 1 depot, i need to try and find a method where it only renames files with certain names

    Only if there is files already in that folder, hope i have explained correctly

    If I add for example 3 more files to the folder that already has files, I am calling the files via the snip tool

    1Capture, 2 Capture, 3Capture

    Another way I can put this is:

    If 1-Postcode, 2-Postcode, 3-POstcode files already exist, DO NOT rename these files, just the files called, the 3 newly added capture files are the only ones that want renaming.

    Code:
    Dim sPath As String, sDelTo As String, strPC As StringDim sOldFile As String, sNewFile As String
    Dim i As Integer, iIndex As Integer
    
    
    sDelTo = Me.txtName
    strPC = Me.txtPC
    
    
    If Left(Me.cboLocation, 1) = "H" Then
        
        sPath = "C:\Users\davem\Desktop\Maps\" & sDelTo & "\"
    
    
    End If
    
    
    If Left(Me.cboLocation, 1) = "W" Then
    
    
        sPath = "C:\Users\David\Desktop\Maps\" & sDelTo & "\"
    
    
    End If
    
    
            sOldFile = Dir(sPath & "*.jpg")
            
            While sOldFile <> ""
            
                i = i + 1
    
    
                sNewFile = i & "-" & strPC & ".jpg"
            
                Name sPath & sOldFile As sPath & sNewFile
            
                sOldFile = Dir
        
            Wend
    I am thinking something like:

    If Len(Dir(sPath & sNewFile)) >0

    How do i not rename existing files, just ones called 1Capture etc......

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,820
    You could specify files on/after given date or a filename pattern:

    filename LIKE "*Capture*"

    or

    Instr(filename, "Capture") > 0
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,643
    Personally I like using fso when dealing with files and folders. Much easier to work with the methods like FileExists, getBaseName, BuildPath, MoveFile, etc. Unfortunately I cant quite get my head around your criteria to make any suggestions.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Dave,

    Can you show some examples
    -what you have
    -what you need
    - and the issue of multiple depots?

  5. #5
    DMT Dave is offline VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,185
    Hi Guy's thank you for responding, Can I apologize, i have slightly changed the goal post here, what I thought of afterwards is changing

    MkDir company name
    to
    MkDir company name & Postcode

    so when a company name has more than 1 depot I can then add a map jpg to the relevant folder and (NOW A POSTCODE FOLDER WITHIN THAT COMPANY)

    @moke123 yes i have used fd in the past but got so used to using Dir and Name as, but you guy's are always brilliant on suggesting methods that is no doubt the best options

    This has done the trick though as the Postcode allows me to add Jpg files to 1 customer folder with varying postcodes

    Thanks again to you all

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Storing and Renaming Files Outside of Access
    By JohnSmith in forum Access
    Replies: 1
    Last Post: 03-30-2017, 03:34 AM
  2. Replies: 10
    Last Post: 09-09-2015, 03:25 AM
  3. Renaming Files in a Folder
    By Jen in forum Modules
    Replies: 5
    Last Post: 06-01-2015, 04:55 PM
  4. Replies: 1
    Last Post: 05-15-2015, 10:58 AM
  5. Renaming Files using data from a table or query
    By enzokevin in forum Programming
    Replies: 7
    Last Post: 10-17-2014, 05:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums