Results 1 to 12 of 12
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,097

    Dir not finding files

    A folder with files like this:

    Click image for larger version. 

Name:	003.jpg 
Views:	15 
Size:	140.5 KB 
ID:	52542

    A module that is looking for them with the Dir function:

    Click image for larger version. 

Name:	002.jpg 
Views:	15 
Size:	205.3 KB 
ID:	52543

    Dir finds the 1st two files you see in the screenshot, but none of the others. (You'll see my Debug.Print in the IW) I'm in mystery as to why the other files aren't returned.

    Each file name is comprised of 6 tokens separated by semicolons ";" with the ".mp3" file extension on the end. (periods appear where one would normally expect colons but one cannot use colons in file names.)

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I can only guess it has something to do with the semi-colons in file name.

    Really should provide code as text, not image. Cannot copy/paste code from image.

    I don't see anything that will print each filename to IW.

    I would not expect colons in date values, only in time parts.

    Are you saying records are not created?
    Does SComments field allow empty string?
    Is SDate a date/time field? "2024.11.10.0" is not a valid date structure.
    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
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,097
    We've been processing these mp3 files literately for years, but I can't say I ever remember processing folders with Dir like I'm trying to do now. I'll twiddle with one of the file names with substitutions for the semicolon to see if your suspicions reveal anything.

  4. #4
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    I agree with that response, unless maybe it's acceptable in some locales to use one semi colon in a file name instead of a dot/period. Then again, never 2 consecutive ones since the first of a repeated character usually escapes the second one, and who knows what shenanigans that will raise?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,097
    Semicolon not the issue. I changed the field delimiters with a simple rename to use underscore and re-ran the sub, but Dir still not finding the file.

    Code:
    Private Sub cmdImport_Click()
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    '  This sub looks first at the sermon portal where audio files are passed
    '  to the TMS host machine within the LAN.  Secondly, the sub will interrogate
    '  the downloadsAdjusted to see if any audio files have been extracted from
    '  Youtube videos and adjusted to the TMS format that also need to be
    '  imported.
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    Dim strSerFldr As String
    Dim strNewSer As String
    Dim strTMSfmt() As String
    Dim rsSermons As DAO.Recordset
    
    
    strSerFldr = DLookup("InstSerLib", "InstProperties")
    
    
    Set rsSermons = DBEngine(0)(0).OpenRecordset("QSermons")
    
    
    With rsSermons
    Debug.Print strSerFldr & "DownloadsAdjusted\" & "*.mp3"
    strNewSer = Dir(strSerFldr & "DownloadsAdjusted\" & "*.mp3")
        Do While Len(strNewSer) <> 0
            strTMSfmt = Split(strNewSer, "_")
            If UBound(strTMSfmt) = 5 Then
                .AddNew
                !SDate = strTMSfmt(0)
                !SBook = strTMSfmt(1)
                !SReference = strTMSfmt(2)
                !SPresenter = strTMSfmt(3)
                !SComments = strTMSfmt(4)
                !SFileType = strTMSfmt(5)
                !SDuration = GetDuration(strSerFldr, strNewSer)
                !SFileName = strNewSer
                .Update
            Else
                MsgBox "Don't recognize format of '" & strNewSer & "'"
            End If
        strNewSer = Dir
        Loop
        
    End With
    
    
    rsSermons.Close
    Set rsSermons = Nothing
    
    
    End Sub
    
    The renamed file: 2024.01.07.0_Psalm_95_Daniel Ransom__.mp3      (eliminating consecutive delimiters made no difference)

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I tested the code with a file of that same name (also tested with semi-colons). No problem finding.

    What happens if you put Debug.Print strNewSer after Do While line?

    Have you step debugged?
    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.

  7. #7
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,097
    The adjusted code as you suggest:
    The IW when I run the code:

    Graeagle Community Church Live Stream-1.mp3
    Graeagle Community Church Live Stream.mp3

    Code:
    Private Sub cmdImport_Click()
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    '  This sub looks first at the sermon portal where audio files are passed
    '  to the TMS host machine within the LAN.  Secondly, the sub will interrogate
    '  the downloadsAdjusted to see if any audio files have been extracted from
    '  Youtube videos and adjusted to the TMS format that also need to be
    '  imported.
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    Dim strSerFldr As String
    Dim strNewSer As String
    Dim strTMSfmt() As String
    Dim rsSermons As DAO.Recordset
    
    
    strSerFldr = DLookup("InstSerLib", "InstProperties")
    
    
    Set rsSermons = DBEngine(0)(0).OpenRecordset("QSermons")
    
    
    With rsSermons
    'Debug.Print strSerFldr & "DownloadsAdjusted\" & "*.mp3"
    strNewSer = Dir(strSerFldr & "DownloadsAdjusted\" & "*.mp3")
        Do While Len(strNewSer) <> 0
        Debug.Print strNewSer
            strTMSfmt = Split(strNewSer, "_")
            If UBound(strTMSfmt) = 5 Then
                .AddNew
                !SDate = strTMSfmt(0)
                !SBook = strTMSfmt(1)
                !SReference = strTMSfmt(2)
                !SPresenter = strTMSfmt(3)
                !SComments = strTMSfmt(4)
                !SFileType = strTMSfmt(5)
                !SDuration = GetDuration(strSerFldr, strNewSer)
                !SFileName = strNewSer
                .Update
            Else
                MsgBox "Don't recognize format of '" & strNewSer & "'"
            End If
        strNewSer = Dir
        Loop
        
    End With
    
    
    rsSermons.Close
    Set rsSermons = Nothing
    
    
    End Sub

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Then I have no idea what is wrong. Code works for me.
    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.

  9. #9
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    I am going to go with .mp3) is not the same as .mp3 ?

    Which of course could be confirmed just by walking the code.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  10. #10
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    I was about to say the same thing - also think your date format of 2024.12.01.0 won't work if your sDate field is a date datatype.

    Depends on your regional settings but

    ?cdate("2024.12.01.0") generates a datatype mismatch error

    my regional setting use a -

    cdate("2024-12-01") works

    but with .0 or -0 or <space>0, they all generate the same mismatch error

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Oh, doh! So obvious! I did NOT test with paren.

    But I did mention issue of date data type in post 2 as well as possible issue of empty string, which I never allow in fields.
    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.

  12. #12
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    2,097
    I'm with June7, doh! If I had looked at my own post #1 sample screenshot of the file directory like our good friends in the UK did............ maybe I?

    SDate is a string. Perhaps a more descriptive name would be more appropriate. (The string format is yyyy.mm.dd.n, where "n" is the day's file generation value, as there can be multiple sermons on the same date.)

    GetDuration Function didn't care for the ".mp3)" file type either

    !SDuration = GetDuration(strSerFldr, strNewSer)

    Public Function GetDuration(ByVal p_FolderPath As String, ByVal p_FileName As String) As String

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

Similar Threads

  1. Len(Dir.............. not finding file
    By GraeagleBill in forum Programming
    Replies: 4
    Last Post: 07-06-2022, 08:52 AM
  2. Replies: 6
    Last Post: 09-12-2019, 12:23 PM
  3. Replies: 1
    Last Post: 05-22-2018, 07:47 AM
  4. Replies: 14
    Last Post: 05-24-2017, 02:22 PM
  5. aSTR = Dir("C:\*.*") >> "Type Mismatch"
    By JGrant in forum Programming
    Replies: 1
    Last Post: 03-28-2009, 05:17 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