{文件目录扫描}
列出当前目录下所有文件名(本级)
DIR *.* /B >list1.txt
定位与多级完整路径用: DIR D:\文件夹 *.* /b/s /B >list-s.TXT
-------------------------------------------------------------------------------------------
列出当前目录下所有文件的完整路径(树形多级)
tree /f > list2.txt
-------------------------------------------------------------------------------------------
列出当前目录下所有文件的完整路径(多级)
@echo off
set "B=A"
for %%a in (%B%) do for /f "delims=" %%b in ('dir /a-d/b/s *') do (
echo %%b >>list3.txt
)
pause
-------------------------------------------------------------------------------------------
列出某个目录下所有指定匹配的文件完整路径(多级)
@echo off
set "FileName=*.zip"
set "A=D:\文件夹"
for %%a in (%A%) do for /f "delims=" %%b in ('dir /a-d/b/s %%a\%FileName%') do (
echo 搜索中..........................
echo %%b >>list4.txt
)
echo 完毕!
pause
-------------------------------------------------------------------------------------------
列出某个目录下所有文件名,去后缀(本级)
@echo off
@for /F "tokens=*" %%a in ('dir C:\ /B') do @echo %%~na >> list5.txt
pause
-------------------------------------------------------------------------------------------
列出某个目录下所有文件名(本级)
@echo off
set B="D:\文件夹"
for %%a in (%B%) do for /f "delims=" %%b in ('dir D:\文件夹 /b /B' ) do (
echo %%b >>list6.txt
)
pause
-------------------------------------------------------------------------------------------
列出某个目录下所有文件文件完整路径(多级)
@echo off
set B="D:\文件夹"
for %%a in (%B%) do for /f "delims=" %%b in ('dir D:\文件夹 /b/s /B' ) do (
echo %%b >>list7.txt
)
pause
-------------------------------------------------------------------------------------------
列出局域网共享目录下所有文件文件完整路径(多级)
@echo off
set B="A"
for %%a in (%B%) do for /f "delims=" %%b in ('dir \\192.168.1.99\公司文件 /b/s /B' ) do (
echo %%b >>list8.txt
)
pause
{文件删除}
删除文件夹文件
rd /s /q C:\A
删除文件
del C:\A.txt 添加询问 del /s C:\A.txt