简体   繁体   English

"如何批量删除文件名中包含特殊字符的文件"

[英]How to mass remove files that contain special characters in file name

Google Drive went a little crazy and create multiple iterations of files by appending multiples of "(1)", "(1) (1)" to the file names. Google Drive 有点疯狂,通过在文件名上附加多个“(1)”、“(1) (1)”来创建文件的多次迭代。 So far I've been able to get a decent list of them with their path by using:到目前为止,我已经能够通过使用以下方法获得一份体面的清单及其路径:

tree -f -ifpugDs $PWD | grep -e '(1) (1)' | cut -d "]" -f 2 > output.txt<\/code>

Now I'm having trouble on how to delete them with the rm command.现在我在如何使用 rm 命令删除它们时遇到了麻烦。 I Don't mind deleting a few of them by hand that the filter didn't pick up ( like "(2) (1)" ), but there are around 45K of them that the filter matched with.我不介意手动删除其中一些过滤器没有拾取的内容(例如 "(2) (1)" ),但过滤器匹配的其中大约有 45K。

"

This will delete every file whose name ends in (1)<\/code> , recursively:这将递归删除名称以(1)<\/code>结尾的每个文件:

find . -name '*(1)' -exec rm {} +

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM