Two. The copy function in Win8/Win10 has the pause button and won't interrupt the process on duplicates or R/O - it will postpone the dialog until the all the normal files will be processed. Also, it warns you about insufficient space before the start.
Three. Powershell here to help. So we want to give a friend our playlist. It has to have size and full path, but must be sorted by the filename. Oh, and we don't want to let anyone know that we're fans of gurly music. Let's see:
Four. Metamorphose is great but in case you need it literally in batch:
:: so John somehow knows that we love Bieber. we need to make him fired (and then killed)
:: find his actual reports on the company server
$files = Get-Childitem -Path \\sales\reports -Recurse -File -Include *john.doc -Exclude archive* -Depth 2
:: turn profits into losses and add some illegal stuff
ForEach ($f in $files) { Rename-Item $f -NewName ($f.Name -Replace '^profit_','loss_' -Replace 'cars','crack' ) }
It could be written as a oneliner with minor changes (minus foreach, plus pipes).
Five. Your toddler is not great with computers and has somehow merged the projects folder into itself - five times. And there is no backup. Let's clean the mess:
get-childItem *.* | get-filehash | group hash | where { $_.count -gt 1 } | foreach { $_.group | select-object -skip 1 } | del
Eight. The copy function in Win8/Win10 will bring you a dialog with options what to do with same files. It has some downsides (like, not fully automatic), so welcome back to the user-friendly Powershell:
robocopy C:\project D:\backup *.* /XO
P.S. Look, guys, somebody thinks this comment form is a good idea and all, but I can't enter a numbered list without having it renumbered. Not funny, lads. And the edited changes aren't displayed after being submitted.
Senior DevOps Engineer with 9+ years of experience. Otherwise an avid artist, reader, cinephile & football fan. Looking forward to connecting with everyone :)
Wow! I admire that kind of commitment towards solving any problems via Powershell, Caigan but as I mentioned previously, sometimes you wish for a GUI to click & sort your troubles away.
Out of curiosity, what are some of your other favorite hacks in Powershell for use on a daily basis?
Just FYI: You could enclose the comments within `` for code, e.g:
get-childItem *.* | get-filehash | group hash | where { $_.count -gt 1 } | foreach { $_.group | select-object -skip 1 } | del
And * or 1. to start bulleted and numbered lists respectively, cheers :)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Two. The copy function in Win8/Win10 has the pause button and won't interrupt the process on duplicates or R/O - it will postpone the dialog until the all the normal files will be processed. Also, it warns you about insufficient space before the start.
Three. Powershell here to help. So we want to give a friend our playlist. It has to have size and full path, but must be sorted by the filename. Oh, and we don't want to let anyone know that we're fans of gurly music. Let's see:
Get-ChildItem *.* -Recurse -Exclude Brit*,Spic*,Bieb* | Sort-Object BaseName | Format-Table Length, FullName | Out-File zzmusic.txt
Four. Metamorphose is great but in case you need it literally in batch:
:: so John somehow knows that we love Bieber. we need to make him fired (and then killed)
:: find his actual reports on the company server
$files = Get-Childitem -Path \\sales\reports -Recurse -File -Include *john.doc -Exclude archive* -Depth 2
:: turn profits into losses and add some illegal stuff
ForEach ($f in $files) { Rename-Item $f -NewName ($f.Name -Replace '^profit_','loss_' -Replace 'cars','crack' ) }
It could be written as a oneliner with minor changes (minus foreach, plus pipes).
Five. Your toddler is not great with computers and has somehow merged the projects folder into itself - five times. And there is no backup. Let's clean the mess:
get-childItem *.* | get-filehash | group hash | where { $_.count -gt 1 } | foreach { $_.group | select-object -skip 1 } | del
Eight. The copy function in Win8/Win10 will bring you a dialog with options what to do with same files. It has some downsides (like, not fully automatic), so welcome back to the user-friendly Powershell:
robocopy C:\project D:\backup *.* /XO
P.S. Look, guys, somebody thinks this comment form is a good idea and all, but I can't enter a numbered list without having it renumbered. Not funny, lads. And the edited changes aren't displayed after being submitted.
P.P.S. No more code in comments from me.
Wow! I admire that kind of commitment towards solving any problems via Powershell, Caigan but as I mentioned previously, sometimes you wish for a GUI to click & sort your troubles away.
Out of curiosity, what are some of your other favorite hacks in Powershell for use on a daily basis?
Just FYI: You could enclose the comments within `` for code, e.g:
get-childItem *.* | get-filehash | group hash | where { $_.count -gt 1 } | foreach { $_.group | select-object -skip 1 } | del
And * or 1. to start bulleted and numbered lists respectively, cheers :)