PDA

View Full Version : [File Batch] cancellare files vecchi?


Magnum2000
22-03-2005, 16:45
Ciao ragazzi.
Vorrei creare un file batch che elimini da una directory tutti i files più vecchi di una data prestabilita...

Dare il comando "DEL" o "ERASE" non è un problema, ma è l'IF (data) che non so settare.... :rolleyes:

Qualcuno può darmi maggiori informazioni? :(

Thanks :D

tglman
22-03-2005, 17:33
di so dire come fare un programma che esegue queste operazioni ma non ti so dire come farlo in batch (perchè non saprei come prendere la data )

Se ti interessa il programma scrivi.. ciao..

Magnum2000
22-03-2005, 17:46
Originariamente inviato da tglman
di so dire come fare un programma che esegue queste operazioni ma non ti so dire come farlo in batch (perchè non saprei come prendere la data )

Se ti interessa il programma scrivi.. ciao..

Per programma cosa intendi? Un eseguibile in VB?

DigitalKiller
22-03-2005, 18:41
Questo batch verifica se il file passato come argomento è stato creato o modificato oggi (data di sistema). L'ho appena trovato e non ho avuto il tempo di provarlo. Non so se può esserti utile


@ECHO OFF
REM * MODIFIED.BAT
REM * Check if specified file was created or modified today

REM * Needs write access to current directory; or add fully qualified
REM * path to files CURRENT.BAT and its language dependent versions,
REM * and make sure its path is specified in the PATH variable.

REM * File name should be specified
IF "%1"=="" GOTO Syntax
IF NOT EXIST %1 GOTO Syntax

REM * Send DIR output for specified file to primary temporary
REM * batch file to get the file's creation or modification date
DIR %1 | FIND /I "%1" > %TEMP%.\~ISMODIF.TMP
ECHO.>> %TEMP%.\~ISMODIF.TMP
TYPE %TEMP%.\~ISMODIF.TMP | TIME | FIND /I "%1" > %TEMP%.\~ISMODIF.BAT
REM * Create secondary temporary batch files to be called by primary
ECHO SET CHKDATE=%%4>ENTER.BAT
REM * For Dutch DOS versions
ECHO SET CHKDATE=%%5>VOER.BAT
ECHO SET CHKDATE=%%6>TYP.BAT
CALL %TEMP%.\~ISMODIF.BAT

REM * Send DIR output for temporary batch file to itself to get today's date
DIR %TEMP%.\~ISMODIF.BAT | FIND /I "~ISMODIF.BAT" > %TEMP%.\~ISMODIF.TMP
ECHO.>> %TEMP%.\~ISMODIF.TMP
TYPE %TEMP%.\~ISMODIF.TMP | TIME | FIND /I "~ISMODIF.BAT" > %TEMP%.\~ISMODIF.BAT
REM * Create secondary temporary batch files to be called by primary
ECHO SET NOWDATE=%%4>ENTER.BAT
REM * For Dutch DOS versions
ECHO SET NOWDATE=%%5>VOER.BAT
ECHO SET NOWDATE=%%6>TYP.BAT
CALL %TEMP%.\~ISMODIF.BAT

REM * Compare dates and display result
IF "%NOWDATE%"=="%CHKDATE%" ECHO %1 was created or modified today (%NOWDATE%)

REM * Clean up the mess
DEL %TEMP%.\~ISMODIF.BAT
DEL %TEMP%.\~ISMODIF.TMP
DEL ENTER.BAT
DEL VOER.BAT
DEL TYP.BAT
SET CHKDATE=
SET NOWDATE=
GOTO End

:Syntax
ECHO MODIFIED.BAT
ECHO Check if specified file was created or modified today
ECHO.
ECHO.
ECHO Usage: %0 filename

:End

tglman
22-03-2005, 22:34
intendo un programma scritto in visual c ma forse se riesci ha trovare i comandi batch ti puoi risparmiare un pò di fatica(poca..)

Ciao..

Magnum2000
23-03-2005, 10:41
Originariamente inviato da DigitalKiller
Questo batch verifica se il file passato come argomento è stato creato o modificato oggi (data di sistema). L'ho appena trovato e non ho avuto il tempo di provarlo. Non so se può esserti utile
[/I]

Veramente interessante....
;)

Grazie a tutti :)