compression - Powershell Scripting - Zipping, Moving BAK files to a new folder named for the date of BAK file creation -


firstly, hello , apologies stupidly long title...

secondly, hope out there can should simple task has annoyed me past 4days, elaborate;

  1. i have 4 x bak file created between 22:30 , 23:00hrs each night.
  2. each bak file named differently , append date in format "yyyy_mm_dd".
  3. i need 7z each bak file separate archives , move them new directory either named date created or appended date of file keep format "yyyy_mm_dd". (both same code different, whichever easiest)

i believe have separate lines of script need...

  • for creating 7z

dir *.bak | foreach-object { & "c:\program files\7-zip\7z.exe" -t7z -mx3 ($.name+".7z") $.name }

  • for creating folder

$folder = new-item -itemtype directory -path "drive2:\folder1\folder2\$((get-date).tostring('yyyy-mm-dd'))"

  • for moving files

get-childitem 'drive1:\folder1\folder2\*.7z' | copy-item -destination $folder

can point out being complete nugget this?

thanks in advance

robd

if files copy in drive1:\folder1\folder2, missing slash between folder , wildcard.

get-childitem 'drive1:\folder1\folder2\*.7z' | copy-item -destination $folder 

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -