packagefrimport("os""path/filepath""regexp")varredundant=regexp.MustCompile(` \(\d+\)$`)funcisRedundant(filenamestring)bool{ext:=filepath.Ext(filename)filenameWithoutExt:=filename[:len(filename)-len(ext)]ifredundant.Match([]byte(filenameWithoutExt)){returntrue}returnfalse}funcremoveFile(pathstring){println("Remove "+path)os.Remove(path)}funcFindRedundant(dirPathstring){// walk all files in directoryfilepath.Walk(dirPath,func(pathstring,infoos.FileInfo,errerror)error{if!info.IsDir(){ifisRedundant(info.Name()){removeFile(path)}}returnnil})}