View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
pgarcia pgarcia is offline
external usenet poster
 
Posts: 304
Default Batch Delete VB code

Ya, blasphemer!

"Charlotte E." wrote:

How about an alternative?



WHAT!?!?

There's an alternative to using Excel!?!?!

:-)




Open windows explorer.
Traverse to your My Music folder
Search for *.m4a
Include subfolders in your search
after the search is finished
click on the results window (to the right)
Ctrl-a
to select all those files.
hit the delete key on the keyboard.

pgarcia wrote:

I found the following code. Does any one know if this will run
through the sub folders? I have around 200 folder and need to delete
.m4a files. Thanks

Sub test()
MyPath = "C:\Documents and Settings\My Documents\My Music"
Set fs = CreateObject("Scripting.FileSystemObject")

LastRow = Range("A1").End(xlDown).Row

For r = 2 To LastRow
fs.DeleteFile MyPath & Cells(r, "A").Value
Cells(r, "A").ClearContents ' Remove file from list after
deleting it Next

End Sub