pingu256
Goto Top

Variable Dateien verschieben nach Abgleich - Erweitert

Variable Dateien verschieben nach Abgleich

Hallo zusammen ich habe erneut eine Frage zu folgender Problemstellung
-> Variable Dateien verschieben nach Abgleich


hier die damalige Lösung

Zitat von @Ren:
Ich hatte kopiert gelesen, ich bin schon müde. Aber das sollte ja
kein Ding sein, ersetzt man copy durch move, wenn man sich sicher ist,
dass im Zielverzeichnis nichts kaputt gehen kann, move /y. Sonst
müsste man halt vorher noch nachsehen, ob die Datei schon
existiert.
> @echo off
> set "verzeichnis=e:\pdfs"  
> set "ziel=e:\ziel"  
> :loop
> FOR /F "delims=" %%i IN ('dir %verzeichnis%\*.pdf  
> /b') DO call :handle "%%i"  
> ping -w 60000 1.1.1.1 -n 1 >nul
> goto :loop
> 
> :handle
> set "file=%~1"  
> set "file2=%~n1.pd$"  
> if exist "%verzeichnis%\%file2%" move /y  
> "%verzeichnis%\%file2%" "%ziel%\%file2%" &  
> move /y "%verzeichnis%\%file%" "%ziel%\%file%"  
> & goto :eof
> goto :eof
> 
> 
> :ende
> 



hat jemand ne Idee wie ich das Script am geschicktesten verändere wenn ich mehrere Verzeichnisse überwachen möchte?

Aktuell sieht der Code so aus und ich überwache Verzeichnis 1 .. hinzu sollen Verzeichnis 2 bis 7 auch überwacht werden sowie die Dateien entsprechen kopiert werden

@echo off
set "verzeichnis=E:\pool\archiv\1"  
set "ziel=x:\ep1\010\"  
set "ziel2=e:\pool\ablage\1"  
:loop
FOR /F "delims=" %%i IN ('dir %verzeichnis%\*.pdf /b') DO call :handle "%%i"  
ping -w 10000 1.1.1.1 -n 1 >nul
goto :loop

:handle
set "file=%~1"  
set "file2=%~n1.pd$"  
if exist "%verzeichnis%\%file2%"   
	copy /y "%verzeichnis%\%file%" "%ziel%\%file%" &   
	copy /y "%verzeichnis%\%file2%" "%ziel%\%file2%" &   
	move /y "%verzeichnis%\%file%" "%ziel2%\%file%" &   
	move /y "%verzeichnis%\%file2%" "%ziel2%\%file2%" &   
	goto :eof
	goto :eof
:ende

Danke!!!
Gruß

pingu256

Content-Key: 107914

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

Printed on: April 19, 2024 at 21:04 o'clock

Mitglied: 60730
60730 Feb 03, 2009 at 16:35:41 (UTC)
Goto Top
Servus,

ich hab mir das nur grob durchgelesen und auch nicht weitergeklickt.

Daher mal als Denkansatz - den ganzen Abfragekram umzustellen:
eine neue Batch mit z.B diesem Inhalt und der aktuelle Code als verschieben.cmd angenommen - ungefähr so:

if exist E:\pool\archiv\1\*.pdf call verschieben.cmd E:\pool\archiv\1" "x:\ep1\010\" "e:\pool\ablage\1"  
if exist E:\pool\archiv\2\*.pdf call verschieben.cmd E:\pool\archiv\2"  "x:\ep1\010\" "e:\pool\ablage\2"  

Und dann die "verschieben.cmd" ungefähr so:
@echo off
set "verzeichnis=%%1"  
set "ziel=%%2"  
set "ziel2=%%3""  
:loop
FOR /F "delims=" %%i IN ('dir %verzeichnis%\*.pdf /b') DO call :handle "%%i"  
ping -w 10000 1.1.1.1 -n 1 >nul
goto :loop

:handle
set "file=%~1"  
set "file2=%~n1.pd$"  
if exist "%verzeichnis%\%file2%"   
	copy /y "%verzeichnis%\%file%" "%ziel%\%file%" &   
	copy /y "%verzeichnis%\%file2%" "%ziel%\%file2%" &   
	move /y "%verzeichnis%\%file%" "%ziel2%\%file%" &   
	move /y "%verzeichnis%\%file2%" "%ziel2%\%file2%" &   
	goto :eof
	goto :eof
:ende

gruß
Member: pingu256
pingu256 Feb 03, 2009 at 18:12:07 (UTC)
Goto Top
die Abfrage soll permanent auf dem Server laufen alle 10 Sekunden .. kann das mit dem Script gewärleistet werden??

Wie müsste es dan aussehen?


Gruß
pingu256
Member: bastla
bastla Feb 03, 2009 at 18:20:15 (UTC)
Goto Top
Hallo pingu256!

(Ungetestet) etwa so:
@echo off & setlocal
set "verzeichnisse=E:\pool\archiv\1,E:\pool\archiv\2,E:\pool\archiv\3,E:\pool\archiv\4,E:\pool\archiv\5,E:\pool\archiv\6,E:\pool\archiv\7"  
set "ziel=x:\ep1\010\"  
set "ziel2=e:\pool\ablage\1"  
:loop
for %%a in (%verzeichnisse%) do 
    for /f "delims=" %%i in ('dir "%%~a\*.pdf" /b') do call :handle "%%i" "%%a"  
    ping -w 10000 1.1.1.1 -n 1 >nul
)
goto :loop

:handle
set "file=%~1"  
set "file2=%~n1.pd$"  
if exist "%2\%file2%" (  
	copy "%2\%file%" "%ziel%\"  
	copy "%2\%file2%" "%ziel%\"  
	move "%2\%file%" "%ziel2%\"  
	move "%2\%file2%" "%ziel2%\"  
)
goto :eof
Soferne sich auch das jeweilige Ziel ändern muss, es aber eine entsprechende Systematik in den Ordnernamen (nämlich jeweils nur die laufende Nummer 1 bis 7) gibt, etwa so:
@echo off & setlocal
set "basisverzeichnis=E:\pool\archiv"  
set "ziel=x:\ep1\010\"  
set "basisziel2=e:\pool\ablage"  
:loop
for /L %%a in (1,1,7) do 
    for /f "delims=" %%i in ('dir "%basisverzeichnis%\%%a\*.pdf" /b') do call :handle "%%i" %%a  
    ping -w 10000 1.1.1.1 -n 1 >nul
)
goto :loop

:handle
set "file=%~1"  
set "file2=%~n1.pd$"  
if exist "%basisverzeichnis%\%2\%file2%" (  
	copy "%basisverzeichnis%\%2\%file%" "%ziel%\"  
	copy "%basisverzeichnis%\%2\%file2%" "%ziel%\"  
	move "%basisverzeichnis%\%2\%file%" "%basisziel2%\%2\"  
	move "%basisverzeichnis%\%2\%file2%" "%basisziel2%\%2\"  
)
goto :eof
Grüße
bastla
Member: pingu256
pingu256 Feb 03, 2009 at 19:03:26 (UTC)
Goto Top
werde ich morgen direkt mal testen


merci !!

Gruß
pingu256