Search

My notebook

Category

Script

PowerShell – show subfolder size.

PowerShell show subfolder size.

gci -force 'D:\folder-name\'-ErrorAction SilentlyContinue | ? { $_ -is [io.directoryinfo] } | % {
$len = 0
gci -recurse -force $_.fullname -ErrorAction SilentlyContinue | % { $len += $_.length }
$_.fullname, '{0:N2} GB' -f ($len / 1Gb)
}

 

Advertisements

Windows – move \ copy files

Move all files older than x days

robocopy "source" "destination" /move /minage:10

Copy files was created from date:

xcopy "source\*.txt" "destination" /D:01-01-2015

Backup files. CMD

Compress files with WINRAR or 7ZIP.

WINRAR

rar m DESTINATIONarc_%date%.rar SOURCE*.*

7ZIP

"c:\Program Files\7-Zip"\7z a -tzip -ssw -mx7 
"Backup\%DATE:~7,2%.%DATE:~4,2%.%DATE:~-4%_FILENAME.zip" 
"Source\*.*"
With password:
"c:\Program Files\7-Zip"\7z a -tzip -ssw -mx7 -p123456 
"D:\Destination\filename_%DATE:/=.%%TIME::=.%.zip" 
"C:\Source\*"

Delete old backups after 10 days:

forfiles /p "Backup_Folder" /s /m *.zip /c "cmd /c Del @path" /d -10

 

Blog at WordPress.com.

Up ↑