jeffwest21
IS-IT--Management
I have the followin g code in a batch file
What happens is this, another batch file sends data in dataed folders to the directory i am looking at, I want to find the latest folder, and get the files out of it and move them elsewhere for a scheduled task to pick up and process. The issue is they are run overnight so no human interaction needs to happen.
I am getting an error that says the folder/file do not exist yet a folder dated today exists and in it are files aslo dated today, this is really bugging me as it will finish off a process I am trying to complete.
'Clever boy...'
Code:
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
SET "FFPath= \\server\ROI\"
SET "NewPath= \\server\ROI\"
REM Arbitrary yyymmdd starting point, nothing will be older than it
SET NewestDate=20130101
ECHO Recursively searching %FFPath%
echo.
FOR /F "delims=" %%I in ('DIR %FFPath%\C*.rtf /a:-d /s /b') DO (
SET FullDate=%%~tI
REM Set CurrDate to yyyymmdd format. Note: Will fail if regional settings changed.
SET CurrDate=!FullDate:~6,4!!FullDate:~0,2!!FullDate:~3,2!
If !CurrDate! gtr !NewestDate! (
SET NewestDate=!CurrDate!
SET NewestFile=%%~fI
)
)
ECHO Copying %NewestFile% to %NewPath%
ECHO.
COPY /Y "%NewestFile%" "%NewPath%"
ECHO.
PAUSE
What happens is this, another batch file sends data in dataed folders to the directory i am looking at, I want to find the latest folder, and get the files out of it and move them elsewhere for a scheduled task to pick up and process. The issue is they are run overnight so no human interaction needs to happen.
I am getting an error that says the folder/file do not exist yet a folder dated today exists and in it are files aslo dated today, this is really bugging me as it will finish off a process I am trying to complete.
'Clever boy...'