陈晓猫

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: :: 管理 ::

遍历目录1(只遍历一级目录)

@echo off
set addisk="E:"
set cpddisk=c:
setlocal EnableDelayedExpansion
for /d %%i in (%systemdrive%\*) do (
set x=%%i
set x=!x:~2!
echo !x!
rem mklink /J "%Addisk%!x!" "%CPddisk%!x!" 1>nul 2>nul
)
pause

 

遍历目录2(遍历所有目录)

@echo off
setlocal EnableDelayedExpansion
for /r %%a in (.) do (
set dirx=%%a
set dirx=!dirx:~,-2!
echo !dirx!
)
pause

 

dir遍历文件(可列举隐藏文件)

@echo off
set file=*.*
rem set Dir=C:\Documents and Settings\Administrator\Application Data\Autodesk\
rem cd /d "%Dir%"
for /f "delims=" %%i in ('dir /b /a-d /s %file%') do (echo "%%i")
echo 操作已完成,任意键退出
pause

posted on 2019-03-06 14:39  陈晓猫  阅读(267)  评论(0编辑  收藏  举报