Logfile Batch

Von: , Frage gestellt am Mo, 4. Feb 2008

Hallo zusammen,
Ich habe einen ordner mit Files:
C\Test\Input\
01.pdf
02.pdf
03.pdf
04.pdf

und einen Zielordner:
C:\Test\Output\
( Hier sollen die PDF Files aus Input hin verschoben werden )

Ziel soll es sein, dass die Files einfach nur kopiert werden und ein logfile geschrieben wird in "C:\Test\%Datum%\sicherung.log"

Das mit dem Verschieben bekomme ich ja noch hin, mit der Log auch so halbwegs. dass ein ordner mit dem Datum angelegt wird schaffe ich nicht...

In "sicherung.log" müsste dann etwa sowas in der Richtung stehen:
04.02.2008 - 12:06:55 moved File "01.pdf" from c:\test\input to c:\test output
04.02.2008 - 12:06:56 moved File "02.pdf" from c:\test\input to c:\test output
04.02.2008 - 12:06:57 moved File "03.pdf" from c:\test\input to c:\test output
04.02.2008 - 12:06:58 moved File "04.pdf" from c:\test\input to c:\test output

MFG. Alex

8 Antworten zu dieser Frage

  1. Antwort von nach einer Stunde 0 hilfreich
    Re: Logfile Batch

    Hallo.

    Hier mal ein Ansatz, für ein komplettes Skript hatte ich jetzt keine Zeit. Vielleicht bekommst du es damit ja selbst hin, sonst melde dich einfach nochmal. Das mit dem Verschieben bekomme ich ja noch hin, mit der Log
    auch so halbwegs. dass ein ordner mit dem Datum angelegt wird
    schaffe ich nicht...

    md  "c:\test\%date%"
    
    In "sicherung.log" müsste dann etwa sowas in der Richtung
    stehen:
    04.02.2008 - 12:06:55 moved File "01.pdf" from c:\test\input
    to c:\test output
    04.02.2008 - 12:06:56 moved File "02.pdf" from c:\test\input
    to c:\test output
    04.02.2008 - 12:06:57 moved File "03.pdf" from c:\test\input
    to c:\test output
    04.02.2008 - 12:06:58 moved File "04.pdf" from c:\test\input
    to c:\test output
    echo %date% - %time% moved file "%file%" from %from% to %to% > c:\test\%date%\sicherung.log
    

    wobei du file, from und to halt vorher noch mit den richtigen Werten füllen musst.

    • Antwort von nach 2 Stunden 0 hilfreich
      Re^2: Logfile Batch

      Meine Batch sieht folgender maßen aus...
      ----
      move c:\ConvertProcess\input\*.* c:\ConvertProcess\output\
      md "c:\ConvertProcess\LOGS\%date%"
      echo %date% - %time% moved file "*.*" from c:\ConvertProcess\input\ to c:\ConvertProcess\output > c:\ConvertProcess\LOGS\%date%\sicherung.log
      ----

      Er erstellt den Ordner auch mit dem Filename, schreib er mir nicht das was ich haben wollte :D
      04.02.2008 - 13:59:21,84 moved file "" from c:\ConvertProcess\input\ to c:\ConvertProcess\output

      Es fehlt noch der Dateiname bei file ""

      Alex

      • Antwort von nach 3 Stunden 0 hilfreich
        Re^3: Logfile Batch

        Hallo. Meine Batch sieht folgender maßen aus...
        ----
        move c:\ConvertProcess\input\*.* c:\ConvertProcess\output\
        md "c:\ConvertProcess\LOGS\%date%"
        echo %date% - %time% moved file "*.*" from
        c:\ConvertProcess\input\ to c:\ConvertProcess\output >
        c:\ConvertProcess\LOGS\%date%\sicherung.log
        ----

        Er erstellt den Ordner auch mit dem Filename, schreib er mir
        nicht das was ich haben wollte :D
        04.02.2008 - 13:59:21,84 moved file "" from
        c:\ConvertProcess\input\ to c:\ConvertProcess\output
        Probier es mal mit

        for %a in (c:\ConvertProcess\input\*.*) do echo %date% - %time% moved file %%a from c:\ConvertProcess\input\ to c:\ConvertProcess\output >> c:\ConvertProcess\LOGS\%date%\sicherung.log
        

        Den move-Befehl musst du dann allerdings nach hinten schieben.

        Sebastian.

        • Antwort von nach 4 Stunden 0 hilfreich
          Re^4: Logfile Batch

          Entweder bin ich doof oder ich bin doof :D
          ich bei mir funktioniert jetzt nichts mehr
          meine Batch sieht so aus:
          -----
          for %a in (c:\ConvertProcess\input\*.*) do echo %date% - %time% moved file %%a from c:\ConvertProcess\input\ to c:\ConvertProcess\output > c:\ConvertProcess\LOGS\%date%\sicherung.log
          move c:\ConvertProcess\input\*.* c:\ConvertProcess\output\
          -----

          • Antwort von nach 4 Stunden 0 hilfreich
            Re^5: Logfile Batch

            Hallo. Entweder bin ich doof oder ich bin doof :D
            ich bei mir funktioniert jetzt nichts mehr
            meine Batch sieht so aus:
            Bekommst du eine Fehlermeldung?
            Außerdem fehlt noch das erzeugen des Ziel-Verzeichnisses für das log-File und ein ">" beim echo (so dass da ">>" steht), sonst wird da immer die Datei überschrieben. Mit >> wird hinten angehangen.

            Also so sollte es eigentlich gehen:

            md "c:\ConvertProcess\LOGS\%date%"
            for %a in (c:\ConvertProcess\input\*.*) do echo %date% - %time% moved file %%a from c:\ConvertProcess\input\ to c:\ConvertProcess\output >> "c:\ConvertProcess\LOGS\%date%\sicherung.log"
            move c:\ConvertProcess\input\*.* c:\ConvertProcess\output\
            


            Sebastian.

            • Antwort von nach 4 Stunden 0 hilfreich
              Re^6: Logfile Batch

              Wenn ich alle 3 Zeilen, einzeln im cmd eingebe, gehts!
              aber als batch will es nicht :D
              Vorschlag?

              Alex [Bei dieser Antwort wurde das Vollzitat nachträglich automatisiert entfernt]

            • Antwort von nach 5 Stunden 0 hilfreich
              Re^7: Logfile Batch

              Hallo. Wenn ich alle 3 Zeilen, einzeln im cmd eingebe, gehts!
              aber als batch will es nicht :D
              Vorschlag?
              Ähm, ja. Hinter dem for muss in Batchdateien ein %% anstelle nur eines % stehen, also insgesamt so:

              md "c:\ConvertProcess\LOGS\%date%"
              for %%a in (c:\ConvertProcess\input\*.*) do echo %date% - %time% moved file %%a from c:\ConvertProcess\input\ to c:\ConvertProcess\output >> "c:\ConvertProcess\LOGS\%date%\sicherung.log"
              move c:\ConvertProcess\input\*.* c:\ConvertProcess\output\
              


              Sebastian.

            • Antwort von nach einem Tag 0 hilfreich
              Re^8: Logfile Batch

              Vielen herzlichen Dank! Es geht alles :) [Bei dieser Antwort wurde das Vollzitat nachträglich automatisiert entfernt]

Keine passende Antwort gefunden? Jetzt eigene Frage stellen!