用批处理列出所有名称为年-月-日格式的文件夹
时间: 2023-02-09 21:19:59 浏览: 199
并打印出它们的名称。
Here's a batch script that lists all folders with names in the format of "YYYY-MM-DD" and prints their names:
```
@echo off
for /d %%F in (*-*) do (
for /f "tokens=1-3 delims=-" %%A in ("%%F") do (
if /i %%A ge 1900 if /i %%A le 2100 (
if /i %%B ge 1 if /i %%B le 12 (
if /i %%C ge 1 if /i %%C le 31 (
echo %%F
)
)
)
)
)
```
This script uses two nested `for` loops. The outer loop `for /d %%F in (*-*)` iterates over all directories that contain a hyphen in their names. The inner loop `for /f "tokens=1-3 delims=-" %%A in ("%%F")` splits the directory name into three parts using the hyphen as a delimiter, and assigns each part to the variables `%%A`, `%%B`, and `%%C`.
The script then checks if each part is within a valid range for the year, month, and day. If all parts are valid, it prints the directory name.
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)