Power shell Script to compress files and save them with timestamp
cd C:\Users\ManasT\Downloads --- Change to Directory
ls haanji* -------- list files starting with haanji
$datestring = (Get-Date).ToString("s").Replace(":","-") --- capture current date and time
& 'C:\Program Files\WinRAR\Rar.exe' a -r C:\Users\ManasT\Downloads\Backup_Test\mytest_$datestring.rar haanji* --- Zip,rename and place the compress file in desired folder
ls haanji* -------- list files starting with haanji
$datestring = (Get-Date).ToString("s").Replace(":","-") --- capture current date and time
& 'C:\Program Files\WinRAR\Rar.exe' a -r C:\Users\ManasT\Downloads\Backup_Test\mytest_$datestring.rar haanji* --- Zip,rename and place the compress file in desired folder
Expected Results :
PS C:\Users\ManasT\Downloads> cd C:\Users\ManasT\Downloads
ls haanji*
$datestring = (Get-Date).ToString("s").Replace(":","-")
& 'C:\Program Files\WinRAR\Rar.exe' a -r C:\Users\ManasT\Downloads\Backup_Test\mytest_$datestring.rar haanji*
Directory: C:\Users\ManasT\Downloads
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 2/17/2016 5:52 PM 7888 haanji.gif
-a--- 2/17/2016 6:14 PM 84528 haanji1_png.png
-a--- 2/17/2016 5:52 PM 14056 haanji_png.png
RAR 5.31 Copyright (c) 1993-2016 Alexander Roshal 4 Feb 2016
Trial version Type RAR -? for help
Evaluation copy. Please register.
Creating archive C:\Users\ManasT\Downloads\Backup_Test\mytest_2016-07-26T13-34-01.rar
Adding haanji.gif 7% OK
Adding haanji1_png.png 86% OK
Adding haanji_png.png 100% OK
Done
No comments