2

Along with Dropbox's Packrat I have a Batch file that I have scheduled to request to run on Mon, Wed and Friday to backup my current project's Photoshop, Fireworks and PHP/WWW files onto a server.

The command is along the lines of:

PAUSE
set "myDate=%date:~6,4% %date:~3,2% %date:~0,2%"
set "myDateNoSpaces=%date:~6,4%%date:~3,2%%date:~0,2%"

mkdir "\\Server\Archive\%myDate%"
copy "A:\File.psd" "\\Server\Archive\%myDate%\File%myDateNoSpaces%.psd"
robocopy "A:\WAMP\www" "\\Server\Archive\%myDate%\www" /MIR

The command does not run regularly, on days where no work has been done on this project i simply close the window rather than pressing a button at the PAUSE prommpt. I also manually run the batch command. This creates an irregular pattern of dates backed up. The PST file is 500MB.

EG:

2014 07 15    <DIR>
2014 07 18    <DIR>
2014 07 22    <DIR>
2014 07 23    <DIR>
2014 07 28    <DIR>
2014 07 30    <DIR>

Within ...\2014 07 20\ we find a folder and a file:

www    <DIR>
                485,435,343   File20140720.pst

What I want to do:

I would like to compare the current PST's size and modified date with the most recently backed up one within the backup date folders before copying. I dont care about checking the WWW files, they change a lot but I rarely edit the PST and its 500MB.

I just dont know how to find the most recent folder when the directory names vary randomly.

I would prefer to use a CMD/DOS, Python or PHP solution rather than a backup application.

TDLR: How do I compare a file to the most recent file of the same type that has a different name in child directories of random names

ZZ9
  • 2,177
  • 2
  • 27
  • 38

1 Answers1

1

Test this:

@echo off
set "yes="
for %%a in ("c:\folder\master.pst") do (
for /r "d:\basefolder" %%b in (*.pst) do if "%%~ta"=="%%~tb" if "%%~za"=="%%~zb" set "yes=%%b"
)
if defined yes echo the file already exists at "%yes%"
foxidrive
  • 40,353
  • 10
  • 53
  • 68
  • Thats exactly what I was looking for. I was not aware of the "for /r" loop, will come in useful in future. Genuinely appreciated, Thanks! – ZZ9 Jul 30 '14 at 17:29