Sorry, non Domo
Some application puts periodical a new photo in a Directory.
So that directory grows and grows.
The photo's have not the same name.
I want to keep maximum the youngest (newest) 10 pictures.
What tool can I use to automatic delete the older files?
Homeseer Pro and Windows7
Anyone used Powershell?
Thanks
Automatic delete files, but keep youngest 10 files
Automatic delete files, but keep youngest 10 files
Best regards, Verkenner
Re: Automatic delete files, but keep youngest 10 files
Just make a vbscript to delete the files based on the date info and let it run in the schedular of Win7 or use a HS event.
Google on - vbscript delete files older then
Example : http://community.spiceworks.com/scripts ... ge-in-days
Google on - vbscript delete files older then
Example : http://community.spiceworks.com/scripts ... ge-in-days
Bram
Re: Automatic delete files, but keep youngest 10 files
Great, was looking for this for a long time 

** edwin **
- Fantic
- Member
- Posts: 201
- Joined: Sat Feb 21, 2009 2:11 pm
- Location: Loenen, UT, Netherlands
- Contact:
Re: Automatic delete files, but keep youngest 10 files
or use this standard windows (vista and up) tool http://technet.microsoft.com/en-us/libr ... 1(v=ws.10)
with this cmd:
rem -----------------------------------------------------------------
rem use the following set of 2 line as many times as you need first set the number of days you want the files to remain
rem keep in mind that you will need to seperate dir name and filename with a space
rem -----------------------------------------------------------------
set DaysToKeepLogs=2
call :RemoveFiles d:\pictures *.jpg
goto :EOF
rem ------------------------------------------------------------------------------
rem Remove the given files (%2) from the given directory (%1)
rem ------------------------------------------------------------------------------
:RemoveFiles
set Dir=%1
set Files=%2
if "%Files%"=="" set Files=*.*
rem *** List files to be removed in logfile ***
%Tools%\forfiles.exe -d-%DaysToKeepLogs% -p%Dir% -m%Files% -c"cmd /c echo %Dir%\@FILE" >>%Log%
rem *** Remove file from server ***
%Tools%\forfiles.exe -d-%DaysToKeepLogs% -p%Dir% -m%Files% -c"cmd /c del %Dir%\@FILE"
goto :EOF
with this cmd:
rem -----------------------------------------------------------------
rem use the following set of 2 line as many times as you need first set the number of days you want the files to remain
rem keep in mind that you will need to seperate dir name and filename with a space
rem -----------------------------------------------------------------
set DaysToKeepLogs=2
call :RemoveFiles d:\pictures *.jpg
goto :EOF
rem ------------------------------------------------------------------------------
rem Remove the given files (%2) from the given directory (%1)
rem ------------------------------------------------------------------------------
:RemoveFiles
set Dir=%1
set Files=%2
if "%Files%"=="" set Files=*.*
rem *** List files to be removed in logfile ***
%Tools%\forfiles.exe -d-%DaysToKeepLogs% -p%Dir% -m%Files% -c"cmd /c echo %Dir%\@FILE" >>%Log%
rem *** Remove file from server ***
%Tools%\forfiles.exe -d-%DaysToKeepLogs% -p%Dir% -m%Files% -c"cmd /c del %Dir%\@FILE"
goto :EOF
Regards, Maarten.
Never let a computer know you're in a hurry.
Never let a computer know you're in a hurry.