ファイルの一括削除について

Deleteアクティビティを使用して、指定したフォルダの中にある複数のファイルを一括削除する方法はありますか?

「AAA」フォルダの中には複数のExcelファイルと、「TTT」フォルダが存在しています。
この際に「TTT」フォルダは残して、Excelファイルのみ一括削除したいです。

ワイルドカードが使用できないためファイル名の指定方法がわかりません。
ご教示いただけると幸いです。

@yuika_maruo

Use below expression to get Excel files from directory and it’s sub directory and it will give you output as Array of string. And then iterate it using For Each loop activity and inside it use Delete activity to delete file.

Directory.GetFiles(“FolderPath”,"*.xlsx",searchOption.AllDirectories)

1 Like

File_Delete.zip (20.0 KB)

1)please give the path in the path variable from which you want to delete files
variable for path is “Path”

  1. In the “File_Types” variable enter the file types which you want to delete in your case it is excel files then give “xlsx” or "xls.(For excel it is already mentioned, if in case you want to delete text files then add the file extensions like “txt” or any of your choice)

  2. This program will delete only the files of mentioned type in “File_Types” in the given directory not the folders

Hope this Helps.

Regards
Ashley Nihal Dcunha

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.