1.

Solve : Check if file exists?

Answer»

Hi All,
I need to create a daily log file that runs down a list of files and checks to be sure that todays files are there. Each day the name of the file changes with a new date stamp added. So far I found a script to create a log file by date and I was able to get the check of a file but I can't get the date in the file name to work.

Here is what I have.....



::::::::::::::::::::::::::::::::::::::::::::::::::::
::Create a log file containing todays date
::LogPath is the path to the folder where the log file will be saved
::LogFileName is a descriptive name that will be added after the date
::LogFileExt is the extension to be used
::First get the date into a variable. Then convert the '/' to '-' so
::the '/' won't be mistaken as a command line switch
::if the file exists, a blank line and a separator line of equal SIGNS
::will be written at the END of the file in CASE the script runs more than
::once a day.
::::::::::::::::::::::::::::::::::::::::::::::::::::
setlocal
set LogPath=C:\Scripts\
set LogFileExt=.log
set LogFileName=Daily BACKUP%LogFileExt%
::use set MyLogFile=%date:~4% instead to remove the day of the week
set MyLogFile=%date%
set MyLogFile=%MyLogFile:/=-%
set MyLogFile=%LogPath%%MyLogFile%_%LogFileName%
::Note that the quotes are REQUIRED around %MyLogFIle% in case it contains a space
If NOT Exist "%MyLogFile%" goto:noseparator
Echo.>>"%MyLogFile%"
Echo.===================>>"%MyLogFile%"
:noseparator
echo.%Date% >>"%MyLogFile%"
echo.%TIME% >>"%MyLogFile%"
:startbatch
::
@echo off
rem check to see if a file exists
if exist "\\peanuts\Applications\FTP\Archive\ABC.XYZEFT2011050420110504*" goto fileexists

goto nofile

:fileexists
echo The file ABC.XYZEFT2011050420110504* exists ya all! >>"%MyLogFile%"
rem other commands here .....
goto end



:nofile
echo the file %1 does not exist
goto end
:end

pause
=========================================

Like I said if I type out the name of the file it writes a line in the log. What I have is about 10 files in 10 places all with date stamps in the name. I am trying to figure out how to run a batch file and then open the log each day to see if any are missing.

Thanks for any help



I figured it out......


Thanks



Discussion

No Comment Found