返回列表 发帖

有偿20支付宝

本帖最后由 HW_99 于 2023-7-2 22:01 编辑

bat求助,两个需求用两个文件实现,bat1:从根目录开始遍历(1、每级子文件夹有.c或者.h文件就输出当前文件夹目录;如果当前还有文件夹就进入重复操作1另存为一个txt文件),bat2:在指定文件夹下的各级文件夹下输出当前文件夹及文件,文件夹另存为:文件夹名.gpj,文件名不变

@echo off&cd /d "%~dp0"
set "out=lastfolderlist.txt"
type nul>"%out%"
for /f "delims=" %%a in ('dir /ad-h/b/s') do (
    set "fd="
    set "f="
    for /f "delims=" %%b in ('dir /a-h/b "%%~a\" 2^>nul') do (
        if exist "%%~a\%%~nxb\" (set /a fd+=1) else (set /a f+=1)
    )
    if not defined fd (
        if defined f (
            set "fdpath=%%~a"
            setlocal enabledelayedexpansion
            >>"%out%" echo;!fdpath:~20!
            endlocal
        )
    )
    pushd "%%~a\"
    dir /a-h/b >"%tmp%\t.t"
    copy /y "%tmp%\t.t" "eachfolder.txt" >nul
    popd
)
pause
exitCOPY
提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

回复 1# HW_99


功能2.bat

请参考Q-04把bat文件保存为ANSI编码:
https://mp.weixin.qq.com/s/Koje4FufWxWBs7ioDy_LJA
@echo off
cd /d "%~dp0"
set "OutFile=当前文件夹和文件.txt"
for /f "delims=" %%i in ('dir /b /s /ad') do (
    >"%temp%\%OutFile%" dir /b /a-d "%%i" 2>nul
    >"%%i\%OutFile%" echo %%i
    >>"%%i\%OutFile%" type "%temp%\%OutFile%"
)COPY
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

返回列表