PC Review


Reply
Thread Tools Rate Thread

Batch Delete VB code

 
 
pgarcia
Guest
Posts: n/a
 
      24th Sep 2008
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
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      24th Sep 2008
How about an alternative?

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


--

Dave Peterson
 
Reply With Quote
 
pgarcia
Guest
Posts: n/a
 
      24th Sep 2008
Thanks, but the problem is, I had to stop my conver of .m4a to .mp3, so I
have list of .m4a that need to be deleted, but also from that list is .m4a
that have not been conver yet. I need to keep those and conver at a later
time. The conver takes a few days as I have round 35Gb of music.

"Dave Peterson" wrote:

> How about an alternative?
>
> 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

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
pgarcia
Guest
Posts: n/a
 
      24th Sep 2008
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

>
>
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      24th Sep 2008
Aren't you afraid that you'll have the same filename used in different
subfolders?

And if you delete by filename alone, you could be deleting the wrong file(s).

I think I'd create a list in excel that includes the path. Then just use

with activesheet
for each mycell in .range("a2",.cells(.rows.count,"A").end(xlup)).cells
on error resume next
kill mycell.value
if err.number <> 0 then
mycell.offset(0,1).value = "Error!"
err.clear
else
mycell.offset(0,1).value = "Deleted"
end if
next mycell
end with

=======
But to answer your original question, no, your code won't look at subfolders.

pgarcia wrote:
>
> Thanks, but the problem is, I had to stop my conver of .m4a to .mp3, so I
> have list of .m4a that need to be deleted, but also from that list is .m4a
> that have not been conver yet. I need to keep those and conver at a later
> time. The conver takes a few days as I have round 35Gb of music.
>
> "Dave Peterson" wrote:
>
> > How about an alternative?
> >
> > 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

> >
> > --
> >
> > Dave Peterson
> >


--

Dave Peterson
 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      24th Sep 2008
And I forgot to toggle my error checking:

with activesheet
for each mycell in .range("a2",.cells(.rows.count,"A").end(xlup)).cells
on error resume next
kill mycell.value
if err.number <> 0 then
mycell.offset(0,1).value = "Error!"
err.clear
else
mycell.offset(0,1).value = "Deleted"
end if
on error goto 0 '<-- added
next mycell
end with

Dave Peterson wrote:
>
> Aren't you afraid that you'll have the same filename used in different
> subfolders?
>
> And if you delete by filename alone, you could be deleting the wrong file(s).
>
> I think I'd create a list in excel that includes the path. Then just use
>
> with activesheet
> for each mycell in .range("a2",.cells(.rows.count,"A").end(xlup)).cells
> on error resume next
> kill mycell.value
> if err.number <> 0 then
> mycell.offset(0,1).value = "Error!"
> err.clear
> else
> mycell.offset(0,1).value = "Deleted"
> end if
> next mycell
> end with
>
> =======
> But to answer your original question, no, your code won't look at subfolders.
>
> pgarcia wrote:
> >
> > Thanks, but the problem is, I had to stop my conver of .m4a to .mp3, so I
> > have list of .m4a that need to be deleted, but also from that list is .m4a
> > that have not been conver yet. I need to keep those and conver at a later
> > time. The conver takes a few days as I have round 35Gb of music.
> >
> > "Dave Peterson" wrote:
> >
> > > How about an alternative?
> > >
> > > 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
> > >
> > > --
> > >
> > > Dave Peterson
> > >

>
> --
>
> Dave Peterson


--

Dave Peterson
 
Reply With Quote
 
pgarcia
Guest
Posts: n/a
 
      24th Sep 2008
Thanks, yes will I was thinking that it would pick up the extension .m4a. You
are correct on that point. Is there a way to pick up the full path? I used
"Command Prompt" to get the name (C:\Documents and Settings\My Documents\My
Music> dir/s>M4A.txt). It does give you all the information, but on different
lines. Do you know of a VB code that will give me a full list of files name
within a director and sub folder too and put it in column A?

Did I say thanks yet? Thank!

"Dave Peterson" wrote:

> And I forgot to toggle my error checking:
>
> with activesheet
> for each mycell in .range("a2",.cells(.rows.count,"A").end(xlup)).cells
> on error resume next
> kill mycell.value
> if err.number <> 0 then
> mycell.offset(0,1).value = "Error!"
> err.clear
> else
> mycell.offset(0,1).value = "Deleted"
> end if
> on error goto 0 '<-- added
> next mycell
> end with
>
> Dave Peterson wrote:
> >
> > Aren't you afraid that you'll have the same filename used in different
> > subfolders?
> >
> > And if you delete by filename alone, you could be deleting the wrong file(s).
> >
> > I think I'd create a list in excel that includes the path. Then just use
> >
> > with activesheet
> > for each mycell in .range("a2",.cells(.rows.count,"A").end(xlup)).cells
> > on error resume next
> > kill mycell.value
> > if err.number <> 0 then
> > mycell.offset(0,1).value = "Error!"
> > err.clear
> > else
> > mycell.offset(0,1).value = "Deleted"
> > end if
> > next mycell
> > end with
> >
> > =======
> > But to answer your original question, no, your code won't look at subfolders.
> >
> > pgarcia wrote:
> > >
> > > Thanks, but the problem is, I had to stop my conver of .m4a to .mp3, so I
> > > have list of .m4a that need to be deleted, but also from that list is .m4a
> > > that have not been conver yet. I need to keep those and conver at a later
> > > time. The conver takes a few days as I have round 35Gb of music.
> > >
> > > "Dave Peterson" wrote:
> > >
> > > > How about an alternative?
> > > >
> > > > 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
> > > >
> > > > --
> > > >
> > > > Dave Peterson
> > > >

> >
> > --
> >
> > Dave Peterson

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      24th Sep 2008
You could use VBA code, but I use this:

http://support.microsoft.com/default...EN-US;q272623&

In fact, I use this version of the .bat file:

==========

@echo off
REM http://support.microsoft.com/default...EN-US;q272623&
dir %1 /-p /b /o:gn /s > "%temp%\Listing.txt"
start notepad "%temp%\Listing.txt"
exit

==========

I created this printdir.bat file in a nice safe folder.

Then I copied the file (using windows explorer) so that I could add a shortcut
to this .bat file to windows explorer rightclick menu.

In WinXP (Home), I could do:
Windows start button|Run
type:
Sendto

And my SendTo folder opens.
For me, it's:
C:\Documents and Settings\(username)\SendTo

Then I rightclicked on an empty spot in that folder and chose to paste shortcut.

Then I could rightclick on any folder in windows explorer and chose Send to,
then PrintDir.

Then I just copy|paste from notepad to what I need--either excel, MSWord, email,
.....








pgarcia wrote:
>
> Thanks, yes will I was thinking that it would pick up the extension .m4a. You
> are correct on that point. Is there a way to pick up the full path? I used
> "Command Prompt" to get the name (C:\Documents and Settings\My Documents\My
> Music> dir/s>M4A.txt). It does give you all the information, but on different
> lines. Do you know of a VB code that will give me a full list of files name
> within a director and sub folder too and put it in column A?
>
> Did I say thanks yet? Thank!
>
> "Dave Peterson" wrote:
>
> > And I forgot to toggle my error checking:
> >
> > with activesheet
> > for each mycell in .range("a2",.cells(.rows.count,"A").end(xlup)).cells
> > on error resume next
> > kill mycell.value
> > if err.number <> 0 then
> > mycell.offset(0,1).value = "Error!"
> > err.clear
> > else
> > mycell.offset(0,1).value = "Deleted"
> > end if
> > on error goto 0 '<-- added
> > next mycell
> > end with
> >
> > Dave Peterson wrote:
> > >
> > > Aren't you afraid that you'll have the same filename used in different
> > > subfolders?
> > >
> > > And if you delete by filename alone, you could be deleting the wrong file(s).
> > >
> > > I think I'd create a list in excel that includes the path. Then just use
> > >
> > > with activesheet
> > > for each mycell in .range("a2",.cells(.rows.count,"A").end(xlup)).cells
> > > on error resume next
> > > kill mycell.value
> > > if err.number <> 0 then
> > > mycell.offset(0,1).value = "Error!"
> > > err.clear
> > > else
> > > mycell.offset(0,1).value = "Deleted"
> > > end if
> > > next mycell
> > > end with
> > >
> > > =======
> > > But to answer your original question, no, your code won't look at subfolders.
> > >
> > > pgarcia wrote:
> > > >
> > > > Thanks, but the problem is, I had to stop my conver of .m4a to .mp3, so I
> > > > have list of .m4a that need to be deleted, but also from that list is .m4a
> > > > that have not been conver yet. I need to keep those and conver at a later
> > > > time. The conver takes a few days as I have round 35Gb of music.
> > > >
> > > > "Dave Peterson" wrote:
> > > >
> > > > > How about an alternative?
> > > > >
> > > > > 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
> > > > >
> > > > > --
> > > > >
> > > > > Dave Peterson
> > > > >
> > >
> > > --
> > >
> > > Dave Peterson

> >
> > --
> >
> > Dave Peterson
> >


--

Dave Peterson
 
Reply With Quote
 
pgarcia
Guest
Posts: n/a
 
      24th Sep 2008
Oh mannnnnnnnnnnnnn!!!!!!! That was awsom!!!
It worked like a charm. I've made a .bat once, but how does this one work?
What is
REM http://support.microsoft.com/default...EN-US;q272623& about?


Thanks

"Dave Peterson" wrote:

> You could use VBA code, but I use this:
>
> http://support.microsoft.com/default...EN-US;q272623&
>
> In fact, I use this version of the .bat file:
>
> ==========
>
> @echo off
> REM http://support.microsoft.com/default...EN-US;q272623&
> dir %1 /-p /b /o:gn /s > "%temp%\Listing.txt"
> start notepad "%temp%\Listing.txt"
> exit
>
> ==========
>
> I created this printdir.bat file in a nice safe folder.
>
> Then I copied the file (using windows explorer) so that I could add a shortcut
> to this .bat file to windows explorer rightclick menu.
>
> In WinXP (Home), I could do:
> Windows start button|Run
> type:
> Sendto
>
> And my SendTo folder opens.
> For me, it's:
> C:\Documents and Settings\(username)\SendTo
>
> Then I rightclicked on an empty spot in that folder and chose to paste shortcut.
>
> Then I could rightclick on any folder in windows explorer and chose Send to,
> then PrintDir.
>
> Then I just copy|paste from notepad to what I need--either excel, MSWord, email,
> .....
>
>
>
>
>
>
>
>
> pgarcia wrote:
> >
> > Thanks, yes will I was thinking that it would pick up the extension .m4a. You
> > are correct on that point. Is there a way to pick up the full path? I used
> > "Command Prompt" to get the name (C:\Documents and Settings\My Documents\My
> > Music> dir/s>M4A.txt). It does give you all the information, but on different
> > lines. Do you know of a VB code that will give me a full list of files name
> > within a director and sub folder too and put it in column A?
> >
> > Did I say thanks yet? Thank!
> >
> > "Dave Peterson" wrote:
> >
> > > And I forgot to toggle my error checking:
> > >
> > > with activesheet
> > > for each mycell in .range("a2",.cells(.rows.count,"A").end(xlup)).cells
> > > on error resume next
> > > kill mycell.value
> > > if err.number <> 0 then
> > > mycell.offset(0,1).value = "Error!"
> > > err.clear
> > > else
> > > mycell.offset(0,1).value = "Deleted"
> > > end if
> > > on error goto 0 '<-- added
> > > next mycell
> > > end with
> > >
> > > Dave Peterson wrote:
> > > >
> > > > Aren't you afraid that you'll have the same filename used in different
> > > > subfolders?
> > > >
> > > > And if you delete by filename alone, you could be deleting the wrong file(s).
> > > >
> > > > I think I'd create a list in excel that includes the path. Then just use
> > > >
> > > > with activesheet
> > > > for each mycell in .range("a2",.cells(.rows.count,"A").end(xlup)).cells
> > > > on error resume next
> > > > kill mycell.value
> > > > if err.number <> 0 then
> > > > mycell.offset(0,1).value = "Error!"
> > > > err.clear
> > > > else
> > > > mycell.offset(0,1).value = "Deleted"
> > > > end if
> > > > next mycell
> > > > end with
> > > >
> > > > =======
> > > > But to answer your original question, no, your code won't look at subfolders.
> > > >
> > > > pgarcia wrote:
> > > > >
> > > > > Thanks, but the problem is, I had to stop my conver of .m4a to .mp3, so I
> > > > > have list of .m4a that need to be deleted, but also from that list is .m4a
> > > > > that have not been conver yet. I need to keep those and conver at a later
> > > > > time. The conver takes a few days as I have round 35Gb of music.
> > > > >
> > > > > "Dave Peterson" wrote:
> > > > >
> > > > > > How about an alternative?
> > > > > >
> > > > > > 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
> > > > > >
> > > > > > --
> > > > > >
> > > > > > Dave Peterson
> > > > > >
> > > >
> > > > --
> > > >
> > > > Dave Peterson
> > >
> > > --
> > >
> > > Dave Peterson
> > >

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
pgarcia
Guest
Posts: n/a
 
      24th Sep 2008
Ah, you wouldn't mind look at this post, would you? Thanks if you do:
Subject: Lotus Notes VB code (yes, it works)

"Dave Peterson" wrote:

> You could use VBA code, but I use this:
>
> http://support.microsoft.com/default...EN-US;q272623&
>
> In fact, I use this version of the .bat file:
>
> ==========
>
> @echo off
> REM http://support.microsoft.com/default...EN-US;q272623&
> dir %1 /-p /b /o:gn /s > "%temp%\Listing.txt"
> start notepad "%temp%\Listing.txt"
> exit
>
> ==========
>
> I created this printdir.bat file in a nice safe folder.
>
> Then I copied the file (using windows explorer) so that I could add a shortcut
> to this .bat file to windows explorer rightclick menu.
>
> In WinXP (Home), I could do:
> Windows start button|Run
> type:
> Sendto
>
> And my SendTo folder opens.
> For me, it's:
> C:\Documents and Settings\(username)\SendTo
>
> Then I rightclicked on an empty spot in that folder and chose to paste shortcut.
>
> Then I could rightclick on any folder in windows explorer and chose Send to,
> then PrintDir.
>
> Then I just copy|paste from notepad to what I need--either excel, MSWord, email,
> .....
>
>
>
>
>
>
>
>
> pgarcia wrote:
> >
> > Thanks, yes will I was thinking that it would pick up the extension .m4a. You
> > are correct on that point. Is there a way to pick up the full path? I used
> > "Command Prompt" to get the name (C:\Documents and Settings\My Documents\My
> > Music> dir/s>M4A.txt). It does give you all the information, but on different
> > lines. Do you know of a VB code that will give me a full list of files name
> > within a director and sub folder too and put it in column A?
> >
> > Did I say thanks yet? Thank!
> >
> > "Dave Peterson" wrote:
> >
> > > And I forgot to toggle my error checking:
> > >
> > > with activesheet
> > > for each mycell in .range("a2",.cells(.rows.count,"A").end(xlup)).cells
> > > on error resume next
> > > kill mycell.value
> > > if err.number <> 0 then
> > > mycell.offset(0,1).value = "Error!"
> > > err.clear
> > > else
> > > mycell.offset(0,1).value = "Deleted"
> > > end if
> > > on error goto 0 '<-- added
> > > next mycell
> > > end with
> > >
> > > Dave Peterson wrote:
> > > >
> > > > Aren't you afraid that you'll have the same filename used in different
> > > > subfolders?
> > > >
> > > > And if you delete by filename alone, you could be deleting the wrong file(s).
> > > >
> > > > I think I'd create a list in excel that includes the path. Then just use
> > > >
> > > > with activesheet
> > > > for each mycell in .range("a2",.cells(.rows.count,"A").end(xlup)).cells
> > > > on error resume next
> > > > kill mycell.value
> > > > if err.number <> 0 then
> > > > mycell.offset(0,1).value = "Error!"
> > > > err.clear
> > > > else
> > > > mycell.offset(0,1).value = "Deleted"
> > > > end if
> > > > next mycell
> > > > end with
> > > >
> > > > =======
> > > > But to answer your original question, no, your code won't look at subfolders.
> > > >
> > > > pgarcia wrote:
> > > > >
> > > > > Thanks, but the problem is, I had to stop my conver of .m4a to .mp3, so I
> > > > > have list of .m4a that need to be deleted, but also from that list is .m4a
> > > > > that have not been conver yet. I need to keep those and conver at a later
> > > > > time. The conver takes a few days as I have round 35Gb of music.
> > > > >
> > > > > "Dave Peterson" wrote:
> > > > >
> > > > > > How about an alternative?
> > > > > >
> > > > > > 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
> > > > > >
> > > > > > --
> > > > > >
> > > > > > Dave Peterson
> > > > > >
> > > >
> > > > --
> > > >
> > > > Dave Peterson
> > >
> > > --
> > >
> > > Dave Peterson
> > >

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to code a batch file to delete specific folder? Eric Windows XP General 3 27th Apr 2010 09:17 AM
Re: How to batch-delete directories within XPE? Sean Liming \(MVP\) Windows XP Embedded 0 3rd Dec 2008 10:35 AM
Batch Delete Help jeffbg123 Windows XP General 6 14th Jun 2007 07:26 PM
batch delete =?Utf-8?B?amFzb24yNDQ0?= Microsoft Excel Misc 1 21st Sep 2006 04:01 AM
batch delete Karl Windows XP Help 5 17th Feb 2005 06:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:28 AM.