The principle of substitution is to change the time of the file and replace it with the modified time to teach early.
Set desdir=D:set filetypes=pdf uvproj Bat c H s LibCPPtxt Rardel/s/q s:\backtempsrc.t>Nuldel/s/q s:\backtempdes.t>Nuldel/s/q s:\dellist.t>Nulcls@echo off&setlocal Enabledelayedexpansionset/P sels="is data redundancy scanned? (y/n) sel="if "%sels%"=="Y"Goto Section1goto Section2:section1EchoDelete redundant files-----------------------------------------Echo-file Scanning for/F"delims="%%iinch('CD') DoSet srcdir=%%I for/F"delims="%%iinch('dir/s/b') Do(Set Thistemp=%%IEcho!thistemp:%srcdir%=!>>s:\backtempsrc.t) for/F"delims="%%iinch('dir/s/b "%desdir%"') Do(Set Thistemp=%%IEcho!thistemp:%desdir%=!>>s:\backtempdes.t)Echo-file Comparison for/F"delims="%%iinch(S:\BACKTEMPDES.T) Do(Set Flags=1 for/F"delims="%%jinch(S:\BACKTEMPSRC.T) Do (if "%%i"=="%%j"Set flags=0)if!flags!==1 (Echo%desdir%%%IEcho%%i>>s:\dellist.t))ifexist s:\dellist.t ( for/F"delims="%%iinch(S:\DELLIST.T) Do(RD/s/q"%desdir%%%i">>Nuldel/s/q"%desdir%%%i">>nul))Echoredundant file deletion completeEcho*****************************************************Echo.Echo.: Section2EchoStart Backup:------------------------------------------- for%%iinch(%filetypes%) Do(xcopy*.%%i"%desdir%\ "/s/i/d/h/r/y)Echo _____________________________________________________Echo.Echobackup complete Press any key to exit! Pause>Nuldel/s/q s:\backtempsrc.t>Nuldel/s/q s:\backtempdes.t>Nuldel/s/q S:\dellist.t>nul
Note that my computer has a S-disk, which is a virtual memory disk, so the temporary generated files are put there, if there is no need to change the batch of s:\ letter.
(BY:CNTSW reprint Please specify the source)
Write a batch process, you can implement file backup, automatic comparison to delete redundant files.