search all my folders find specific documet and delete

rjmdc

Well-known Member
Joined
Apr 29, 2020
Messages
743
Office Version
  1. 365
Platform
  1. Windows
hi
i need some help
i need to reveiw all files in a specific file path
find any document ending with: (Report Date 11.14.2024).xlsx and DELETE it
what would the code be?
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
How about:

VBA Code:
Sub DeleteFileStr()
    Dim fldrPath As String
    Dim fileStr As String
    Dim filePath As String
    Dim file As String
    
    fldrPath = "C:\Your\Folder\Path\" ' make sure to include '\' at the end
    fileStr = "(Report Date 11.14.2024)"
    file = Dir(fldrPath & "*.*")
    Do While file <> ""
        If InStr(file, fileStr) > 0 Then
            filePath = fldrPath & file
            Kill filePath
        End If
        file = Dir
    Loop
End Sub
 
Upvote 0
hi
where does this get placed? i started a new book and create the code and pressed run but nothing happened
 
Upvote 0
This would do too (only change your folderpath)

VBA Code:
Sub jec()
Kill "C:\Users\xxx\Downloads\*(Report Date 11.14.2024).xlsx"
End Sub
 
Upvote 0
hi
i am sorry
file name ENDS with (Report Date 11.14.2024).xlsx
it is not the full file name
 
Upvote 0
this code isnt working
the file name ends with (Report Date 11.14.2024).xlsx
the file has a whole long name before that
how do i search my folders and kill thaose files
 
Upvote 0
i need to reveiw all files in a specific file path
What is the specific file path? Are there any subfolders involved? Post a few examples of the full file names.
 
Upvote 0
base folder
"M:\AALL CONSUMERS\_AALL FI\4__BUDGETS APPROVED\
folder names ex in this folder
there are a few hundred folders
"M:\AALL CONSUMERS\_AALL FI\4__BUDGETS APPROVED\last name, first name(QU-broker TABS 123456)"
search for this folder in the folder - folder 51
"M:\AALL CONSUMERS\_AALL FI\4__BUDGETS APPROVED\last name, first name(QU-broker TABS 123456)\51_Payments"
kill any file that ends in (Report Date 11.14.2024).xlsx</
 
Upvote 0
tahnk you all
i found a code previously used in my agency that worked
 
Upvote 0

Forum statistics

Threads
1,226,693
Messages
6,192,463
Members
453,725
Latest member
cvsdatreas

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top