I need to copy newest file from one folder to another folder where i need to validate like if the file is same in the both folder then i should not copy the file.

I have two folders folder A and folder B .now from folder A  we need to pick the newest file and copy it to folder B   and we need to validate the files like if the new file picked and the file existing in folder B are same then we should give warning message. using batch script.
suresh ThippaniAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tahir QureshiSystem AnalystCommented:
0
Stuart DrydenAutomation solutions architect & senior technical support engineerCommented:
Do you have to use Windows Batch?  Some basic PowerShell would be far easier.
0
NVITEnd-user supportCommented:
This does it.
Make a .bat file of this.

- Change the variable values of FolderA, FolderB, and FNLog to your needs.
- This .bat is in test mode. To run it for real, remove the ECHO on line 18.
- In addition, a log of results is sent to file FNLog.

@echo off
setlocal enabledelayedexpansion

REM I have two folders folder A and folder B.
REM From folder A we need to pick the newest file and copy it to folder B.
REM If the new file picked and the file existing in folder B are same then 
REM we should give warning message.

set FolderA=C:\local\test\EE\src
set FolderB=c:\local\test\EE\tgt
set FNLog=c:\local\test\EE\log.txt

pushd %FolderA%
for /f %%D in ('dir /b /a-d /o-d "%FolderA%"') do (
  if exist "%FolderB%\%%~nxD" (
    >> "%FNLog%" echo %date% %time% "%FolderB%\%%~nxD" exists
  ) else (
    copy /y "%%~fD" "%FolderB%\%%~nxD"
    >> "%FNLog%" echo %date% %time% !errorlevel! copy result of "%FolderB%\%%~nxD"
  )
  REM pause
  goto :eof
)
popd

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NVITEnd-user supportCommented:
Question answered.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.