import os
import re

main_path = os.path.dirname("C:\\windows\\temp\\")
main_path_list_dir = os.listdir(main_path)

mal_ware_pattern = re.compile(r"AskToolbar")

save_dir = []
save_path = []


# 以迴圈處理
for f in main_path_list_dir:

    # 產生檔案的絕對路徑
    full_path = os.path.join(main_path, f)

    # 判斷 full_path 是檔案還是目錄
    if os.path.isdir(full_path):
        save_dir.append(full_path)

for path in save_dir:
    for dirPath, dirNames, fileNames in os.walk(path):
        for f in fileNames:
            if mal_ware_pattern.match(f):
                save_path.append(path)

if save_path :
    for path in save_path:
        print(path)
        os.remove(path)
else:
    print("No more AskToolbar Path")
