dir "*.exe" | % {."$_"}
公告版位
星落的瞬間!放棄的後悔是永遠!
目前分類:powershell (3)
- Nov 24 Wed 2010 21:44
[powershell]依續執行目錄下的所有exe
- Nov 02 Tue 2010 21:27
用powershell寫一個把目前目錄下的程式碼都轉換成utf8的程式(日文也ok)
# 只能轉與系統同編碼的ansi
function tounicode($orginFile = $(throw "input file required"))
{
$data = get-content $orginFile
set-content -value $data $orginFile -encoding utf8
}
# 可以自定來源編碼
function tounicode($orginFile = $(throw "input file required"), $coding = 'Shift-JIS')
{
#$data = get-content $orginFile
- Oct 19 Tue 2010 19:25
power shell 幫我清除obj
dir -r | % {if ($_ -like "*.obj") {del $_.FullName} }
解釋:
dir 列出目錄
-r 遞迴進入子目錄
| 把資料傳給...
% 就是foreach
{ 要做的事 }
if 判斷
$_ 傳來的參數簡寫
-like 字串比較