file exists with condition today's date -


i have folder files dumped timestamps... filename_ver20130405121320.csv

i wish create batch script makes sure 5 files have been created todays date.

im guessing need use loop date limit of today.

for /r %foldername% %%g in (*.csv) (     echo %%~nxg  ) 

using forfiles statement lists files, possible use counter , +=1 every time displays filename?

forfiles /s /p %foldername% /m *.csv /d 0  

the logic

if number of files in foldername less 5 file created today  echo error! missing files 

any appreciated

date returned on machine mon 22/07/2013 use set date

:: set date  /f "tokens=1* delims= " %%a in ('date/t') set cdate=%%b /f "tokens=1,2 eol=/ delims=/ " %%a in ('date/t') set dd=%%b /f "tokens=1,2 delims=/ eol=/" %%a in ('echo %cdate%') set mm=%%b /f "tokens=2,3 delims=/ " %%a in ('echo %cdate%') set yyyy=%%b set setdate=%dd%/%mm%/%yyyy% 

@echo off setlocal enabledelayedexpansion set yyyy=2013 set mm=07 set dd=22 set count=0 /f %%g in ('dir /b /a-d *%yyyy%%mm%%dd%????.csv') (  set filename=%%~ng  set filename=!filename:~-12,-4!  if "!filename!"=="%yyyy%%mm%%dd%" set /a count+=1 ) echo %count% goto :eof 

i've set yyyy,mm,dd constants, - poke date-decoder in appropriate.

note prefix filemask directoryname if required - , enclose entire filemask in "rabbit's ears" if there spaces or other confounding characters in resultant mask.

important: filemask merely primary filter. dir list file named filename_ver2013040512132.csv instance (1 digit missing...) gymnastics processing still required.

i'm assuming relatively sane filenames. ! in filename cause conniptions.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -