批处理脚本以列出文件夹,但排除特定文件夹 [英] Batch script to list folders but exclude specific folders

查看:334
本文介绍了批处理脚本以列出文件夹,但排除特定文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望此脚本列出文件夹名称中包含已删除"的所有文件夹,但如果它们位于名为完成"的文件夹中则不列出.

I want this script to list all folders that contains "deleted" in the folder name but not if they is in a folder called "done".

例如:如果文件夹位于C:\tempC:\temp\random_folder_name中,则列出文件夹,但如果文件夹不在C:\temp\done

For exampel: list the folder if it's in C:\temp and if it's in C:\temp\random_folder_name but not not if it's in C:\temp\done

dir /s "C:\temp" | findstr "\deleted"

短篇小说,排除所有名为"done"的文件夹及其内容.

short story, exclude all folders named "done" and their content.

推荐答案

您快到了.

Findstr/v返回不包含字符串的所有行

Findstr /v returns all lines, that do not contain the string

dir/ad仅显示目录(Atrribut = Directory)

dir /ad will only show directories (Atrribut=Directory)

dir /s /ad "C:\temp" | findstr "\deleted" | findstr /v "\done"

这篇关于批处理脚本以列出文件夹,但排除特定文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆