Question: I have a file share, and I want a process which enumerates files on that share and automatically creates a 7z self-extracting exe of *files* over 1 month old. On a different share, I want to create a 7z self-extracting exe of *directories* that are over 1 month old. Any idea if there is a program which can do this? I already have

```
7z a -t7z -mx9 -sfx filename.exe filename.txt 

```

Portion of it, just need more of the auto-management portion.

Running on Windows Server 2008, yes, PowerShell is available. Cygwin would not be an option.

Answer: 
I ended up doing this with a batch file, and setting it to run via Task Scheduler. Here is the batch file if anyone is interested:

```
@echo off

set RETENTION_PERIOD_DAYS=30
set FILE_BASED_ARCHIVES=g:\shares\public\crashes
set DIRECTORY_BASED_ARCHIVES=g:\shares\results
set MINIMUM_FILESIZE=1000000
set ZIP_PATH="c:\Program Files\7-Zip\7z.exe"

if not {%1}=={} call :archive %1 %2 %3 %4&exit /b 0

echo Archiving files older than %RETENTION_PERIOD_DAYS% days.
echo File Based: %FILE_BASED_ARCHIVES%
echo Directory Based: %DIRECTORY_BASED_ARCHIVES%

for %%a in (%FILE_BASED_ARCHIVES%) do (
    echo ********* Archiving %%a
    du /s "%%a"
    echo  -----------------------
    forfiles /p %%a /s /m *.* /d -%RETENTION_PERIOD_DAYS% /c "cmd /c call ^0x22%~dpnx0^0x22 ^0x22FILE^0x22 ^0x22@isdir^0x22 ^0x22@fsize^0x22 @path"
    echo  -----------------------
    du /s "%%a"
    echo ****************************************************
)

for %%a in (%DIRECTORY_BASED_ARCHIVES%) do (
    echo ********* Archiving %%a
    du /s "%%a"
    echo  -----------------------
    forfiles /p %%a /d -%RETENTION_PERIOD_DAYS% /c "cmd /c call ^0x22%~dpnx0^0x22 ^0x22DIR^0x22 ^0x22@isdir^0x22 ^0x22@fsize^0x22 @path"
    echo  -----------------------
    du /s "%%a"
    echo ****************************************************
)

exit /b 0

:archive
    if /i "%~1"=="FILE" (
        if /i "%~2"=="FALSE" (call :archive_file %3 %4) else (echo Skipping %~4 as it is not a file.)
    )
    if /i "%~1"=="DIR" (
        if /i "%~2"=="TRUE" (call :archive_dir %4) else (echo Skipping %~4 as it is not a directory.)
    )
exit /b 0

:archive_file
    set FILESIZE=%~1
    if %FILESIZE% GEQ %MINIMUM_FILESIZE% (
        call :7zip %2 && del /q /f %2
    ) else (
       echo Skipping %~2 as it is smaller than %MINIMUM_FILESIZE% bytes.
    )
exit /b 0

:archive_dir
    call :7zip %1 && rd /q /s %1
exit /b 0

:7zip
    %ZIP_PATH% t "%~1">nul || (
        %ZIP_PATH% a -t7z -mx9 -sfx "%~dp1%~n1.exe" "%~dpnx1" || exit /b 1
    )
exit /b 0

```
Looks like he's running windows guys. (.exe)

Create a shortcut or batch file that runs the command, and then run the shortcut or batch file from Windows Task Scheduler.