Batch Script to Delete Files Older than 30 Days

E Eduardo Cervantes 3 years 5 months ago
20 4 0

Hello All,  I'm trying to create a batch file to run with a file sync rule in Soti's Mobi Control -  Trying to figure this out on Windows Mobile 6.5 as the DOS commands are far more limited than regular MS-DOS.  Would like to delete files (jpg's in this case) in a directory that are older than 30 days.  Any  help, links, appreciated. I keep finding examples with the "forfiles" command but that is not available on this OS.  Motorola ES400 

Please Register or Login to post a reply

4 Replies

E Efkan YILMAZ

I still make change to symscript but have not updated the manual for a few years now.  I do however create example/test scripts - but you would need to look at them to see what is new. If anyone wants the current version plese email me at Paul.hurford@motorolasolutions.com

R Richard Linsley-Hood

In C# (which is what you really want to do this sort of programming in - in my opinion) it would be just this below. Of course you would need to add try/catch for a bullet proof soluion.     DateTime CutOffDate = DateTime . Now . AddDays (-30 );     DirectoryInfo di = new DirectoryInfo ( folderPath );     FileInfo [] fi = di . GetFiles ();                  for ( int i = 0 ; i < fi . Length ; i ++)      {          if ( fi [ i ]. LastWriteTime < CutOffDate )          {              File . Delete ( fi [ i ]. FullName );          }      } but if you do not have acces to Visual Studio and know C#...

L Lodi van Elswijk

Paul, I see you posted version 3.15.06 of SymScript back in 2011. I did a quick search through the documentation and the sample files, but it seems the GetFileTime method is neither described nor demonstrated. Have there been any updates since then, either to SymScript itself or the documentation, and if so could you provide us with the latest version? Thanks.

L Lodi van Elswijk

I think you need to turn to scripting or programming, as this is a fairly complex task and the things you can do in a batch file are rather limited. Also, I'm not even sure if you actually can run batch files in Windows Mobile 6.5, because if I recall correctly cmd.exe is not included in the OS. MortScript seems to be able to do what you want. I am not familiar with it myself, but according to the manual it supports requesting the creating and modification dates of a file. You can find it here: http://www.sto-helit.de/index.php?module=page&entry=ms_overview&amp…

CONTACT
Can’t find what you’re looking for?