5 ms·
I'm always found it difficult to read and impossible to debug. It's useful, sure, but nice? I'm not convinced. How about an empty recycle bin command? Why, ce
by shadowmint 13y ago
I'm always found it difficult to read and impossible to debug.
It's useful, sure, but nice? I'm not convinced.
How about an empty recycle bin command? Why, certainly, you can do that:
$Shell = New-Object -ComObject Shell.Application
$RecBin = $Shell.Namespace(0xA)
$RecBin.Items() | %{Remove-Item $_.Path -Recurse -Confirm:$false}
Teh F33243ck. Readable much? I sure hope your powershell scripts come with comments; the one's we've inherited sure didn't and they're black magic.
- oblio 13y agoThat's because they don't have nice, human readable COM (and WMI) wrappers. I don't think they had time to implement them - they kept adding more and more from v1 to v2 and v3. Every time you have Win32 spilling over in Powershell, it looks like crap (0xA).
- lake99 13y agoOver here, on Linux-land, I used to have PS-envy whenever I thought about the PowerShell. You cured me! Though I don't use Trash/Recycle myself, to contrast, I like the simplicity of rm -rf ~/.local/share/Trash/info ~/.local/share/Trash/files
- manojlds 13y agoCommands like Remove-Item have familiar aliases like rm by default. If you see code in tools like Psake, etc. it would be very verbose, because the intention is to have readable code. But you sure can use the aliases for everyday use.
- tomovo 13y agotell application "Finder" empty the trash end tell
- iso8859-1 13y agoIn GNOME: dbus-send --print-reply --dest=org.gnome.Nautilus \ /org/gnome/Nautilus \ org.gnome.Nautilus.FileOperations.EmptyTrash
- ksk 13y agoI agree, Powershell is definitely uglier to look at. To shorten it a bit you could also do this.. gci \'$Recycle.Bin' -Force -Recurse | ?{-not $_.PSIsContainer} | Remove-Item -Force