Question: i use this script to compress all .txt and .cpi files into the backup folder in separated files with 7zip. After the files are zipped i delete the original files. However this script has a logical flaw. Lets say if the 7zip program fails to run, the files will also get deleted. How can i change the script so that it should not delete the files if they don't get zipped first. Also how can i change this script so it zips files that are older than 7 days? Thanks for your help.
@echo off  

setlocal 

```
set _source=C:\test7zip\bak    
set _dest=C:\test7zip\bak    
set _wrpath=C:\Program Files\7-Zip        
if NOT EXIST %_dest% md %_dest%    
for %%I in (%_source%\*.txt,%_source%\*.cpi) do "%_wrpath%\7z" a "%_dest%\%%~nI.7z" "%%I" & del "%%I"

```

pause

Answer: 
This is a partial solution to a partial question, but generally you would use:

`ORDER BY YEAR(TimeColumn), DATEPART(m, TimeColumn)`
Try this:

```
ORDER BY DatePart(y,time),DatePart(m,time)

```