Delete files from sub folder if any, else delete the sub folder

Hi,

I have a a master folder ABC and 3 subFolder A, B and C and have two more subfolder of subfolder 1 and 2.

a) Now i have to delete those subfolder and folder which is blank, for example if i have files in subfolder 1 then i will not delete that subfolder also will not delete the B folder too but if i have files in folder B and subfolder 1 is blank then will delete the subfolder 1 only.

b) if subfolder 2 is blank and so do folder C then have to delete both the folders.

image

Hope i able to make my point and here is the attached workflow i have created but not complete need help
DeleteBlank_Folder.xaml (4.6 KB)

1 Like

Hi @indrajit.shah

You can use Stack to implement what you want.
Reference my example.

1 Like

Hi @wusiyangjia

try to use assign activity

strvar=Directory.Delete(path,true)
use delete activity and pass the str variable

Thanks
Ashwin.S

1 Like

Hi @indrajit.shah ,
I am attaching the xaml which i guess i solved the issue,its a nested for loops for checking if there are any directories.If not it will delete the existing files
Deleting the file.xaml (15.0 KB)
If any queries let me know or mark it as solution and close the thread.
Cheers
Vashisht.

1 Like

hi, do you mind attaching the .xaml for the same?

1 Like

@Vashisht thank you for the reply, but it didn’t solve the problem,

Scenario is : -

  1. I have to check the directories and delete it if only blank .
  2. It won’t delete the master folder if there is file/s in any of the folder
  3. I have sub-folders too so if the sub-folder is having files then it will not delete the sub-folder.

P.S I have to delete only those folder which is blank only and for that i have to check the sub-folder 1 1st as per screenshot attached above, if the folder is blank then delete if not have to keep that folder and so the B folder as B Folder is having folder 1 and 1 is having file .

Hope i able to explain my situation.