Delete Old File

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
darioit
Posts: 230
Joined: 02 Aug 2010 05:25

Delete Old File

#1 Post by darioit » 08 Mar 2011 06:09

Hello Everybody,

this is a real difficult works, I show you my problem.
I have a lot of image, and sometimes I had to clean all deleted pic.
My photo archive is organized in this way.

Code: Select all

M:
│───────NIKON_D80
│       └───JPG
│           └───2010-02-10
│                 DSC_02345.JPG
│                 DSC_02346.JPG
│           └───2010-02-11
│                 DSC_02347.JPG
│       └───RAW
│           └───2010-02-10
│                 DSC_02345.NEF
│                 DSC_02346.NEF
│                 ....................
│           └───2010-02-11
│                 DSC_02347.JPG
│                 ....................

│───────NIKON_D7000
│       └───JPG
│           └───2010-03-30
│                 _N7K02345.JPG
│                 _N7K02346.JPG
│           └───2010-03-31
│                 _N7K02347.JPG
│                 ....................
│       └───RAW
│           └───2010-03-30
│                 _N7K02345.NEF
│                 _N7K02346.NEF
│                 ....................
│           └───2010-03-31
│                 _N7K02347.NEF
│                 ....................


Before to see my picture I always make a backup on 2 different hard disk, with the same infrastructure directory.

I work usually with JPG (ex. M:\NIKON_D80\JPG\*) directory to view and discard the photos.

My goal is to synchronize the RAW subdir in main disk, and on the other 2 hard disk JPG and RAW subdir,
when some pic is deleted in main disk folder (M:\NIKON_D80\JPG\* and M:\NIKON_D7000\JPG\*)

All directory and file name are without spaces

Could someone help me with this work?

Regards
Dario

[EDIT aGerman] Code tags complemented and formatted to display the structure well. [/EDIT]

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Delete Old File

#2 Post by aGerman » 08 Mar 2011 16:11

Usually you have to run a DIR /S over the backup, then look for each file whether it still exists on the origin source.

For some reason I didn't understand on which drive letter you delete the files by hand and which drives you try to synchronize :?

Regards
aGerman

darioit
Posts: 230
Joined: 02 Aug 2010 05:25

Re: Delete Old File

#3 Post by darioit » 09 Mar 2011 01:42

Right I must run DIR /S and remove the differences.

on letter M: I delete JPG file, and on letter Y: and X: (backup) I'd like to syncronize with M:

Pheraps software like WinDiff.Exe works fine, but don't delete same file in format NEF

Regards
Dario

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Delete Old File

#4 Post by aGerman » 10 Mar 2011 15:28

Untested for Y:\

Code: Select all

@echo off &setlocal
for /f "tokens=* delims=" %%a in ('dir /a-d /b /s "Y:\"') do (
  if not exist "M:%%~pnxa" ECHO del "%%~a"
)
pause

Remove the ECHO command if it displays the right files for deleting.

Regards
aGerman

Post Reply