本帖最后由 ttszuo 于 2015-8-13 10:04 编辑
昨天突然想到可以用dir+*来获取文件路径,不过代码比较多需要简化一下- @echo off
- setlocal enabledelayedexpansion
- set "Temp1=C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp"
- set Temp1=%Temp1:\= %
- for %%a in (%Temp1%) do (
- set name=%%a
- set name1=!name:~-2,1!
- set name2=!name:~0,1!
- cd /d "!flies!"
- if "!name1!"=="~" (
- for /f "delims=" %%i in ('dir /b/a "!flies!!name2!*"') do (
- if "%%~sfi"=="!flies1!!name!" (
- set "flies=%%~fi\"
- set "flies1=%%~sfi\"
- )
- )
- ) else (
- set "flies=!flies!!name!\"
- set "flies1=!flies1!!name!\"
- )
- )
- if not exist "!flies!" set flies=!flies:~0,-1!
- echo.!flies!
- pause
复制代码
|