December 4, 2021
Hello, and thank you in advance! I just got a new job (1 month now), and we migrated, so our emails and logins are all different (one company name to another). And during the process, we got double emails on everything. And all of our documents doubled. So it is just a nightmare. I am trying to clean up, and I would like to be able to offer this macro to the team as well so they can do easy clean-ups on their computer. I want to be able to:
1. BROWSE to select the folder
2. Look at ALL folders, sub-folders and every additional folder in the hierarchy
3. Have all files containing " - Copy." (regardless of what the file extension is) deleted
This is what i have so far. It does work, however, I must do each folder separately, and the folder path is hard-coded, so it is not what I want/need.
Sub CleanDupesCopy()
'Delete all .xlsx files using the * wildcard character
Kill "C:\Users\barnesh\OneDrive - HII\Documents\HII\Training\Onboarding\* - Copy.*"
End Sub
October 5, 2010
Hi Sherry,
I'd try using the Command Prompt rather than VBA for this.
See if del "C:\Users\barnesh\OneDrive - HII\Documents\HII\Training\Onboarding\* - Copy.*" /s does the trick
If you open a Cmd Prompt and navigate to the Onboarding (or any other) folder you could just use
del "* - Copy.*" /s
Note that I haven't tested this but think it should work. Please test it yourself before using.
You can always add a /p flag to the command to make it prompt for confirmation before doing any deletions.
Regards
Phil
Answers Post
December 4, 2021
@Philip Treacy,
Thanks so much, that was a great solution. I never thought of using the command prompt. All my duplicates are gone (about 15K files or so!). Problem solved. It was easy and painless, thanks again!
The following users say thank you to Sherry Fox for this useful post:
Philip Treacy1 Guest(s)