Hi ,
With the below code i can able to delete the Empty Folders/Files from the Directory.But am Struck when i move to the subfolders of the main folders.
![]()
Please Login or Register to view this content.
Thanks,
lax
Hi ,
With the below code i can able to delete the Empty Folders/Files from the Directory.But am Struck when i move to the subfolders of the main folders.
![]()
Please Login or Register to view this content.
Thanks,
lax
Use a coding technique called Recursion where a procedure calls itself for each subfolder. Then if that subfolder has its own subfolders, the procedure calls itself again for each of those. It's not that hard to do. This link explains it well
Recursion And The FileSystemObject
You could find several other helpful sites by searching for something like Excel VBA Recursion.
Surround your VBA code with CODE tags e.g.;
[CODE]your VBA code here[/CODE]
The # button in the forum editor will apply CODE tags around your selected text.
Hello laxmanann,
This should save you some time. Here is a macro that will recursively remove empty folders in just the main folder or optionally remove all empty folders in the sub folders.
The argument SearchSubfolders is optional. If this argument is not included in the call, it defaults to False. False will search only the main folder. Setting this argument to True will search all subfolders.
Macro Code
Example of calling the Macro![]()
Please Login or Register to view this content.
![]()
Please Login or Register to view this content.
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
dear alphafrog,
Thanks for the help..but with the above code I can able to list out the files present in the folder/directory and I can able to delete the files present in the main folder.but I want to delete all the empty files and folders present in the subfolders of the main folder.pls help me
Thanx,
Lax
Dear Ross,
Much thanks for the help.@alphafrog .sorry..thanks for the help.actually my reply and Ross 's valueable comment reached in the same time..but my comment reached a seconds late in the post..Thank you ppl again..
@Ross..how could I thank you man..no words..Searching in google to thank you.but I din get a SPL word other thank you..sorry for tat two dear Ross.
Thanks,
Lax
Hello Lax,
You're welcome. Glad I could help out.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks