martinoli
Goto Top

2 Batch skript zusammen fügen

Hallo zusammen

Ich hab mal vor 3 Tagen oder so gefragt wie ich am besten Unterordner dursuchen kann (und Unterordner vom Unterordner face-smile).
Darauf hin hab eich ein bisschen hielfe bekommen.

Jedenfalls Hab ich es jetzt Fertig: (Skript1)

@echo off
set a=00
set b=01
for /d %%i in ("%userprofile%\Desktop\Test Ordner") do (for /d %%j in ("%%~fi\*") do echo "%%~fj")
for /d %%i in ("%userprofile%\Desktop\Test Ordner\*") do (for /d %%j in ("%%~fi\*") do echo "%%~fj")
:BATCH
echo es geht
for /d %%i in ("%userprofile%\Desktop\Test Ordner\%a%\*") do (for /d %%j in ("%%~fi\*") do echo "%%~fj")
set /a a=%a%+%b%
set c=2000
set d=0
:JAHR
echo es geht
for /d %%i in ("%userprofile%\Desktop\Test Ordner\%a%\%c%\*") do (for /d %%j in ("%%~fi\*") do echo "%%~fj")
IF %d%==0 goto D0
IF %d%==9 goto D10
IF %d%==99 goto D100
:D0
IF %c%==2000 (set e=00)
IF %c%==2001 (set e=01)
IF %c%==2002 (set e=02)
IF %c%==2003 (set e=03)
IF %c%==2004 (set e=04)
IF %c%==2005 (set e=05)
IF %c%==2006 (set e=06)
IF %c%==2007 (set e=07)
IF %c%==2008 (set e=08)
IF %c%==2009 (set e=09)
IF %c%==2010 (set e=10)
IF %c%==2011 (set e=11)
IF %c%==2012 (set e=12)
IF %c%==2013 (set e=13)
IF %c%==2014 (set e=14)
IF %d%==0 goto String1
IF %d%==10 goto String2
IF %d%==100 goto String3
:D10
set d=10
IF %d%==0 goto String1
IF %d%==10 goto String2
IF %d%==100 goto String3
:D100
set d=100
IF %d%==0 goto String1
IF %d%==100 goto String3
IF %d%==10 goto String2
:STRING1
for /d %%i in ("%userprofile%\Desktop\Test Ordner\%a%\%c%\%a%.%e%.00%d%\*") do (for /d %%j in ("%%~fi\*") do echo "%%~fj")
set /a d=%d%+%b%
IF %d%==9 goto D10
IF %d% NEQ 9 goto STRING1
:STRING2
for /d %%i in ("%userprofile%\Desktop\Test Ordner\%a%\%c%\%a%.%e%.0%d%\*") do (for /d %%j in ("%%~fi\*") do echo "%%~fj")
set /a d=%d%+%b%
IF %d%==99 goto D100
IF %d% NEQ 99 goto STRING2
:STRING3
for /d %%i in ("%userprofile%\Desktop\Test Ordner\%a%\%c%\%a%.%e%.%d%\*") do (for /d %%j in ("%%~fi\*") do echo "%%~fj")
set /a d=%d%+%b%
IF %d%==200 goto C
IF %d% NEQ 200 goto STRING3
:C
set d=0
set /a c=%c%+%b%
IF %c%==2015 goto Reset
IF %c% NEQ 2015 goto JAHR
:RESET
IF %a%==1 (set a=01)
IF %a%==2 (set a=02)
IF %a%==3 (set a=03)
IF %a%==4 (set a=04)
IF %a%==5 (set a=05)
IF %a%==6 (set a=06)
IF %a%==7 (set a=07)
IF %a%==8 (set a=08)
IF %a%==9 (set a=09)
IF %a%==100 goto FERTIG
IF %a% NEQ 100 goto BATCH
:FERTIG
pause

(Dieses Skript macht, dass es die Ordner, Unterordner und Unterordner von den Unterordner anzeigt.)

So und jetzt muss ich noch hinzufügen das es nur die LEEREN Ordner anzeigt.
Skript2:

@echo off
pause

(Diese Skript zeigt ALLE leeren Ordner an in dem es liegt.)

Ich muss die jetzt so kombinieren das es nur die vorher gesuchten Ordner (Skript1), auf leere Ordner durchsucht (Skript2) und nicht ALLE.

Kann mir jemand helfen? Wenn ihr mehr Infos brauch oder eine bessere Idee habt für das Skript2 sagt es bitte.

Gruss Martinoli

Content-Key: 222732

Url: https://administrator.de/contentid/222732

Printed on: April 26, 2024 at 07:04 o'clock

Member: Endoro
Endoro Nov 22, 2013 updated at 12:44:30 (UTC)
Goto Top
Hi,
was soll dein Code eigentlich machen? Wozu die for-Schleifen?
Runtergebrochen auf aktiven Code und gekürzt:
@ECHO OFF &SETLOCAL
set a=00
set b=01
:BATCH
echo es geht
set /a a=%a%+%b%
set c=2000
set d=0
:JAHR
echo es geht
IF %d%==0 goto D0
IF %d%==9 goto D10
IF %d%==99 goto D100
:D0
if %c% geq 2000 if %c% leq 2014 set "e=%c:~-2%"  
IF %d%==0 goto String1
IF %d%==10 goto String2
IF %d%==100 goto String3
:D10
set d=10
IF %d%==0 goto String1
IF %d%==10 goto String2
IF %d%==100 goto String3
:D100
set d=100
IF %d%==0 goto String1
IF %d%==100 goto String3
IF %d%==10 goto String2
:STRING1
set /a d=%d%+%b%
IF %d%==9 (goto D10) else goto STRING1
:STRING2
set /a d=%d%+%b%
IF %d%==99 (goto D100) else goto STRING2
:STRING3
set /a d=%d%+%b%
IF %d%==200 goto C else goto STRING3
:C
set d=0
set /a c=%c%+%b%
IF %c%==2015 (goto Reset) else goto JAHR
:RESET
if %a% geq 1 if %a% leq 9 set "a=0%a%"  
IF %a%==100 (goto FERTIG) else goto BATCH
:FERTIG
pause
lg.
Member: loonydeluxe
loonydeluxe Nov 22, 2013 at 21:34:42 (UTC)
Goto Top
Was zum... ich verstehs nicht... was genau soll das tun?

Lässt sich dein Batch-Skript eventuell verkürzen, indem du es rekursiv aufbaust? Also erstmal das eigene Verzeichnis durchsuchen und verarbeiten, anschließend das Skript aufrufen für das Unterverzeichnis aufrufen usw.