1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Some feedback on simple batch file

Discussion in 'Support' started by dcohn, Jul 5, 2008.

  1. dcohn

    Joined:
    Jun 18, 2008
    Messages:
    8
    Likes Received:
    0
    I must have written the following batch file some time ago.

    Can anyone explain if this is more efficient then just running a

    del /[d-15,1/1/80] /s /y http\...\upload\*.jpg

    Is there a performance gain running against a file list?

    Code:
    @echo off
    d:
    cd\
    cd http\domain\uploadtool-pro\upload
    dir /a:d /b >c:\scripts\cleanupdir\dirlisting.txt
    for %files in (@c:\scripts\cleanupdir\dirlisting.txt) del /[d-15,1/1/80] /s /y %files\hi-res\*.jpg >>e:\logs\cleanupdir\%_month%-%_day%-%_year%cleanup.log 
    exit
    additionally can you recommend a way to not log 0 files deleted 4000 times and only show the actual deleted files.

    And last but not least is there a way for these logs to show the total number of files deleted and bytes freed.

    I am needy <G>... Thanks either way

    sample of log snippet


    0 files deleted
    Deleting D:\Photogra\UploadTool-PRO\upload\VENTURA\hi-res\8613945.JPG
    Deleting D:\Photogra\UploadTool-PRO\upload\VENTURA\hi-res\8613947.JPG
    2 files deleted 1,052,672 bytes freed
     
  2. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    dcohn wrote:
    | I must have written the following batch file some time ago.
    |
    | Can anyone explain if this is more efficient then just running a
    |
    | del /[d-15,1/1/80] /s /y http\...\upload\*.jpg
    |
    | Is there a performance gain running against a file list?
    |
    |
    | Code:
    | ---------
    | @echo off
    | d:
    | cd\
    | cd http\domain\uploadtool-pro\upload
    | dir /a:d /b >c:\scripts\cleanupdir\dirlisting.txt
    | for %files in (@c:\scripts\cleanupdir\dirlisting.txt) del /[d-15,1/1/80]
    /s /y %files\hi-res\*.jpg
    >>e:\logs\cleanupdir\%_month%-%_day%-%_year%cleanup.log
    | exit
    | ---------

    The two schemes would not delete the same files.
    - The stand-alone DEL deletes all *.jpg files at least 15 days old from the
    ...\upload directory and all its subdirectories.
    - The "dirlisting" method will not delete anything from the ...\upload
    directory, only from its subdirectories.

    | additionally can you recommend a way to not log 0 files deleted 4000
    | times and only show the actual deleted files.

    You did not specify the command processor you use. If you use V7 or later,
    /Ns option suppresses the summaries.
    |
    | And last but not least is there a way for these logs to show the
    | total number of files deleted and bytes freed.

    You cannot have your cake (final report) and eat it, too (throw away parts
    of the report). You can use FFIND or another method to filter the report
    (e.g. report all lines that do not contain the text " 0 files").

    NOTE that in V9 you can use inverted ranges, i.e., /![d-14] is a range that
    excludes files less that 15 days old.

    --
    HTH, Steve
     
  3. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,203
    Likes Received:
    11
    Have you tried the /E switch on the DEL command? That's what I use when I
    only want to see what's being deleted.

    -Scott



    Steve F畸i疣 <> wrote on 07/06/2008 09:24:00 AM:


    later,

     

Share This Page