One Star

[resolved] How to delete only empty folders?

Hi,
is there a way of deleting all folders in a hierarchy, that are empty?
I've got a tFileList that list all my directories recursivly and a tFileDelete that deletes folders.
But it may not delete them, if they contain files Smiley Sad
Any idea?
Thank you in advance,
Bye, Chris
1 ACCEPTED SOLUTION

Accepted Solutions
Seventeen Stars

Re: [resolved] How to delete only empty folders?

hi,
On *nux you can use :
"rm -r /home/raulier/todelete/"

to delete recursively dir and files "todelete". ... but be very carefull about use it Smiley Happy
Use a tSystem Componenet in Talend to do it

Perhaps you can check if a dir is empty (if count tfilelist = 0 )or not ... delete file if you 're sure about it and use your code to delete dir .
laurent
2 REPLIES
Seventeen Stars

Re: [resolved] How to delete only empty folders?

hi,
On *nux you can use :
"rm -r /home/raulier/todelete/"

to delete recursively dir and files "todelete". ... but be very carefull about use it Smiley Happy
Use a tSystem Componenet in Talend to do it

Perhaps you can check if a dir is empty (if count tfilelist = 0 )or not ... delete file if you 're sure about it and use your code to delete dir .
laurent
One Star

Re: [resolved] How to delete only empty folders?

That's a great idea ..
I just use the system command.
It deletes every folder that is empty.
Other folders won't be deleted (it throws an error, but it is only a string and continous with the task)
Great, thank you Smiley Happy