Hi there, Here my problem, I created somes batch file to perform a backup of somes data every day at work. Here a sample:
@ECHO OFF
ECHO ---------- EXECUTION DE SAUVEGARDE DE DONNEES ----------
ECHO ---------- SVP NE PAS INTERROMPE LE PROCESSUS ----------
Soon
XCOPY /Y "C:\Documents and Settings\portal_user.THS101455\Bureau\*.*" /S /D Y:\Dimanche\bureau\
XCOPY /Y "C:\Documents and Settings\portal_user.THS101455\Mes documents\*.*" /S /D Y:\Dimanche\MesDocs\
XCOPY /Y "C:\PAYCLOCK\Database\*.*" /S /D Y:\Dimanche\payclockdb\
XCOPY /Y "C:\Program Files\RDSoffice Enterprise\Data\Archive\*2009*.*" /S /D Y:\Dimanche\RDS\Archive\
XCOPY /Y "C:\Program Files\RDSoffice Enterprise\Data\Backup\*2009*.*" /S /D Y:\Dimanche\RDS\Backup\
ECHO.
ECHO ---------- EXECUTION DE SAUVEGARDE DE DONNEES ----------My problem, how can I delete files from the backup folder who are not in the original folder anymore. For example, I got "123.xls" on my deskstop monday, the batch file will copy it monday, but the next monday the file "123.xls" is not on my deskstop anymore, but still in my backup... I would like erase this "123.xls" file from backup folder...
Thanks for your help
Best regards
Bullbee
Simplifying the directory structure, if you back up from: c:\files
to:
e:\bakThen you can use the script below. It doesn't *DO* the delete; it previews what's to be done. To activate it, remove the ECHO in front of DEL.
====================
@echo off & setLocal EnableDELAYedeXpansion:pushd e:\bak
for /f "tokens=* delims= " %%a in ('dir/b/a-d') do (
if not exist "c:\files\%%a" (
echo DEL "%%a"
)
)
=====================================
Helping others achieve escape felicityM2
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |