星期一, 4月 18, 2011

Batch FOR

Batch FOR

最近開始要在windows 上研究了,但是batch 並不像cshell那樣直觀,我已經有點燒起來的感覺。
For 迴圈來說,就有四個選項可以選(在介紹文裡都是分開介紹的) orz
FOR /R – 經過每個檔案的迴圈 (會進入每個子資料夾)
FOR /D – 做每個資料夾
FOR /L – 做一個範圍內的數字,(就像傳統迴圈)
FOR /F – 做在一個檔案裡的指令
這是按
help for
跑出來的介紹
對一組檔案中的每個檔案執行指定的命令。
FOR %variable IN (set) DO 命令 [command-parameters]
%variable 指定一個可以取代的參數。
(set) 指定由一或多個檔案組成的檔案組。您可使用通配字元。
command 指定命令來執行每一個檔案。
command-parameters
為所指定的命令指定變數或參數。
如果要在批次程式中使用 FOR 命令,請指定 %%variable,而不要指定
%variable。 變數名稱有大小寫的區分,所以 %i 不同於 %I。如果您啟用擴充命令,則額外支援下列的 FOR 命令
格式:

FOR /D %variable IN (set) DO command [command-parameters]
如果 set 中包含萬用字元,則指定與目錄
名稱相符,而不是與檔案名稱相符。
FOR /R [[drive:]path] %variable IN (set) DO command [command-parameters]
在樹狀目錄中切換 [drive:]路徑,並於樹狀目錄的每一個目錄下執行
FOR 陳述式。如果未在 /R 之後指定目錄規格,則採用目前的目錄。
如果 set 只是單一句點 (.) 字元,則它只會列舉樹狀目錄結構。
FOR /L %variable IN (start,step,end) DO command [command-parameters]
set 是從開頭到結尾一次跳一步的連續數字。所以 (1,1,5) 會產生
連續值 (1 2 3 4 5) 而 (5,-1,1) 會產生連續值 (5 4 3 2 1)
FOR /F ["options"] %variable IN (file-set) DO command [command-parameters]
FOR /F ["options"] %variable IN ("string") DO command [command-parameters]
FOR /F ["options"] %variable IN ('command') DO command [command-parameters]

或,如果使用 usebackq 選項:
FOR /F ["options"] %variable IN (file-set) DO command [command-parameters]
FOR /F ["options"] %variable IN ('string') DO command [command-parameters]
FOR /F ["options"] %variable IN (`command`) DO command [command-parameters]

filenameset 可以是一個以上的檔案名稱。每個檔案都已開啟,
讀取及處理過,才繼續進行下個檔案名稱組。處理檔案讀取的一致
性,將它分成獨立的文字行,然後將每一行分析成零或更多的字串。
用已找到的字串值為變數值,來呼叫 For 迴圈的內容。預設狀態,
/F 傳出每個檔案的每一行中,以空格分隔的第一個字串。空白行
會被略過。您可以指定 "options" 參數來覆寫預設的分析行為。
這是有引號的字串,包含一個以上的關鍵字,來指定不同的分析
選項。關鍵字是:
  • eol=c
    指定一個行尾註解字元(只有一個)
  • skip=n
    指定在檔案開頭要掠過的行數。
  • delims=xxx
    指定分隔符號的集合。 這會取代預設的空白與定位字元的分隔符號集合。
  • tokens=x,y,m-n
    指定每一行的哪些文字串應該被傳到 for 的內部以用來進行每一個重複操作。這會導致額外的變數名稱被配置。m-n 格式代表一個範圍,指定了第 m 個到第 n 個字串項。如果在 tokens= 字串的最後一個字元是星號,則會配置一個額外的變數來接收最後一個字串項被分析後的其他文字。
  • usebackq
    指定新語義開始作用。中反括號的字串會被當作命令來執行,而單引號字串是純文字字串。此外還允許使用雙引號來引用在 filenameset 內的檔名。
以下是一個範例:
FOR /F "eol=; tokens=2,3* delims=, " %i in (myfile.txt) do @echo %i %j %k
這會分析 myfile.txt 檔案中的每一行,它不會去管以分號開頭的行數
,直接將第 2 個及第 3 個語法從每一行傳到 for 主體,而其語法是
用逗號和/或空格分開的。請注意,for 主體陳述式參照 %i 以取得第
二個語法,參照 %j 以取得第三個語法,使用 %k 取得第三個語法之
後的剩餘字串。因為檔案名稱含有空格,您必須用雙引號來括住檔案名
稱。要這樣使用雙引號,您必須使用 usebackq 參數。否則雙引號會被
解譯成用來定義一般文字。
使用 %i 明白地在 for 陳述式中宣告,並透過 tokens= option 使用
%j 作暗式性的宣告。您可以藉由 tokens= line 來指定最多 26 個語
法,前提是它宣告的變數不能高於字母 'z' 或 'Z'。請記住,FOR 變
數是單一字元的,同時在任一時間內,您不能同時使用超過 52 個 FOR
變數。
您也可以使用 FOR /F 命令在立即字串中分析邏輯,方法是將括弧之間的
filenameset 變成一個引號字串。它會被視為從檔案輸入的單行,並加
以分析。
最後,您可以使用 FOR /F 命令來分析一個命令的輸出。方法是將括弧
內的 filenameset 變成單引號字串。它將被視為一個命令列,這個命令
行將會傳到子 CMD.EXE,而輸出將會被擷取到記憶體中,當成檔案來分
析。所以下列的範例:
FOR /F "delims==" %i IN ('set') DO @echo %i
將列舉目前環境中的環境變數名稱。
此外,已經加強了 FOR 變數參考的取代功能。
您現在可以選用下列的語法:
%~I - 展開 %I 且移除包圍的引號 (")
%~fI - 展開 %I 為一個完全符合的路徑名稱
%~dI - 只展開 %I 為磁碟機代號
%~pI - 只展開 %I 為路徑
%~nI - 只展開 %I 為檔名
%~xI - 只展開 %I 為副檔名
%~sI - 展開的路徑只包含短檔名
%~aI - 展開 %I 為檔案的檔案屬性
%~tI - 展開 %I 為檔案的日期/時間
%~zI - 展開 %I 檔案的長度
%~$PATH:I - 搜尋所有列在 PATH 環境變數內的目錄
且展開 %I 為
第一個找到的完全符合檔名。
如果沒有定義環境變數名稱
或是搜尋找不到檔案,
則這個修飾元會展開為
空字串。
修飾元可以合併使用以獲得綜合的結果:
%~dpI - 只展開 %I 為磁碟機代號與路徑
%~nxI - 只展開 %I 為檔名與副檔名
%~fsI - 只展開 %I 為含短檔名的完全路徑
%~dp$PATH:i - 為 %I 搜尋所有列在 PATH 環境變數內的目錄
且展開第一個找到的項目為磁碟機代號及
路徑。
%~ftzaI - 展開 %I 為像 DIR 一樣的輸出行
在上面的範例中 %I 和 PATH 能用其他的合法值取代。%~ 語法是由合法的
FOR 變數名稱來終止。如果選用像 %I 的大寫名稱可以增加可讀性而且避免
和修飾元的混淆,因為這些並不區分大小寫。

(Source: http://nota.tw/index.php/2011/03/20/batch-for-%E5%85%84%E5%BC%9F/)

Batch file - Find out year, month and day

FOR /F "tokens=1-3 delims=/- " %%A IN ('DATE/T') DO (
    SET yyyy=%%A
    SET mm=%%B
    SET dd=%%C
    )
ECHO %yyyy%-%mm%-%dd%

星期一, 10月 18, 2010

Enable wallpaper, multitasking for iPod 2G, iPhone 3G

Edit the below file:
iPhone 3G: /System/Library/CoreServices/SpringBoard.app/N82AP.plist
iPod Touch 2G: iPhone 3G: /System/Library/CoreServices/SpringBoard.app/N72AP.plist

Multi-tasking
multitasking




Wallpaper
homescreen-wallpaper



Battery Percentage
gas-gauge-batteryBoolean



In my experience, wallpapers slowed down my device a lot! The reason for this is the way Apple has implemented the wallpapers, within some pointless overlays. To fix this, simply delete the following files from \System\Library\CoreService\SpringBoard.app:

WallpaperGradientLandscapeBottomT.png
WallpaperGradientLandscapeTopT.png
WallpaperGradientPortraitBottomT.png
WallpaperGradientPortraitTopT.png
WallpaperIconDockShadow.png
WallpaperIconDockShadowT.png
WallpaperIconShadow.png
WallpaperIconShadowT.png

星期三, 10月 13, 2010

Cydia source

http://cydia.hackulo.us
http://sinfuliphonerepo.com
http://iphone.org.hk/apt
http://cydia.xsellize.com
http://apt.dmytro.me
http://app.weiphone.com/cydia
http://iphone.tgbus.com/cydia
http://repo.beyouriphone.com
http://iphonevideorecorder.com/3/
http://www.mcleaner.com/iphone/cydia
http://cydia.pushfix.info
http://elpelle6.com/repo/
http://ispaziorepository.com
http://iphonedelivery.advinux.com/cydia/
http://blackra1n.com
http://www.cmdshft.ipwn.me/apt/
http://apt.mirrordev.com/
http://repo.beyoip.com
http://repo.hackyouriphone.org
http://cydia.myrepospace.com/AppleCloud/
http://gumballtech.com/cydia
http://cydia.allreporelated.com

星期四, 7月 14, 2005

眼訓

最近幾日都知不知什麼原因, 晚上很早係想訓覺, 試個19:30訓了,23:00訓了....
這幾天都是早些入休息啦

星期二, 9月 21, 2004

Freeware replacements for commonly warez'ed programs

Some "cool programs". It's just meant to show that there are free replacements for a lot of commercial software that people commonly pirate.

Links

Free games thread by randumb
Spyware removal thread by Schadenfroh
Snapfiles - Tons of freeware on this site.

Update 8/29/04: I've been out of the country for a month so I haven't been updating. I'll add the new suggestions soon.

** means that I've recently updated the catagory.

As far as I know, none of these programs have spyware. Please let me know if I'm wrong.

Computer protection and maintenance

Antivirus software:
Panda Antivirus - Free for IT Professionals.
Panda Antivirus Link #2 - Free to just about anyone who is affiliated to a school, corporation, or government institution.
If not, then take a look at E-Trust EZ Armor Security Suite - According to Virus Bulletin, this AV suite is better than Avast Antivirus Home Edition or AVG.

Firewall: Kerio Personal Firewall. Kerio seems to be the favorite among forum members. Also take a look at Sygate Personal Firewall. Both are very good and free. The firewall that comes with the E-Trust EZ Armor Security Suite, seems to be the free version of ZoneAlarm.

Spyware scanner: Try Spybot Search and Destroy and Ad-aware.
Also take a look at Schadenfroh's thread about spyware removal.



Office

Office suite: OpenOffice. It's a very professional looking office suite that is compatible (to a certain extent) with Microsoft Office.
AbiWord (Word processor) and 602Pro PC Suite 2001 are good free alternatives too.

PDF maker: CutePDF. It's pretty much the same as PDF955, but without the nag popup. OpenOffice also has an option to export as PDF now.

Email Client: Thunderbird. It's not as full featured as Outlook, but it's a great alternative to Outlook Express. If you want calendar features, take a look at the Calendar plug-in. You can import your settings from Outlook if you export them first to a more generic format (CSV maybe? Don't really remember).
Also look at these free email clients: Eudora (ad sponsored but very good), Foxmail, and Pegasus Mail.

Calendar: Sunbird. I mentioned this application as Calendar along with Thunderbird for an email client, but apparently they made it into a stand-alone application like Thunderbird and Firefox now. *credit goes to beer*

Outlook Express backup: OEBackup. This program seems to simplify the process of backing up OE. Outlook Express doesn't have an easy one-button way to backup all of your emails, settings, and address books. *Found on a website linked by Winchester*

File compression: IZArc - theAnimal suggested this to me. Up until now, I've been using AlZip which was suggested by Flashram. Both programs support tons of compression formats. Neither will let you make RAR files but they can extract RAR files just fine. AlZip is free but has a small, unintrusive ad banner. IZArc doesn't have an ad banner.

Tax software: TaxAct - They let you use their Federal Tax software for free. I tried it out last year and found it to be pretty easy to use.

Presentation/Wizard maker: Wink - (suggested by hasu)
Wink is a Tutorial and Presentation creation software, primarily aimed at creating tutorials on how to use software (like a tutor for MS-Word/Excel etc).


Internet/Networking

FTP server: Filezilla Server - A little more difficult to use than GuildFTP, but I've found it to be a lot faster.

FTP client: Filezilla. Filezilla recently replaced SmartFTP as my preferred FTP client because SmartFTP started to nag me about purchasing a license if I'm a corporate user. Filezilla is great because it supports multiple connections to the FTP server. You can still browse the FTP server while downloading several files. Drag'n'drop support still needs a little work though because you can't drag into Explorer yet.
ugh suggests BlazeFTP. It's pretty similar to Filezilla except that it supports connections to multiple sites using tabs.

SFTP/SCP client: WinSCP. WinSCP is an open source SFTP (SSH File Transfer Protocol) and SCP (Secure CoPy) client for Windows using SSH (Secure SHell). *Found in a thread started by everman

Telnet client: Putty. It's simple, powerful, and free.

Download manager: Star Downloader. It's a nice, clean, simple download manager. My only complaint is that it uses a temporary folder for all downloads. This means that after you download a 600MB file, it still has to COPY the file to your destination folder. I'd also like an option to automatically sort downloads by file type or name. LeechGet. LeechGet is kind of like GetRight lite. Unlike Star Downloader, LeechGet doesn't save the download to a temporary file before copying to your download directory. It also lets you save to different folders based on file type. It has an FTP browser and website parser built in too. The interface is nice although somewhat confusing and there are still a few random bugs. I've tried a lot of different freeware managers such as Star Downloader and FlashGet but I think LeechGet is the best. NOTE: FlashGet contains spyware too.
BFG10K also suggests using NetVampire.

Website copier: HTTrack - An easy-to-use offline browser utility. I've used this utility before and it works great for grabbing tons of files off a website or just copying the website on a superficial level. *Suggested by Nikamichi*



Graphics

Image editing: Gimp. Gimp 2.0 is supposed to be really good, but I managed to get myself a copy of Photoshop CS so I don't really need it. If anyone has a decent review of it, PM me or reply to this thread and I'll add it with credit to you, of course.

If you can spent a little money, I suggest Photoshop Elements. I decided to give Photoshop Elements a try and it worked fine for me. Here's a list of some of the stuff that it doesn't support compared to Photoshop CS: masks, channels, action scripts, complex batch operations, multiple anti-aliasing styles for the text tool, and complex layer effects like drop shadow and buttonizing. PSE has a single anti-aliasing option for text. It supports batch operations but only for resizing and renaming. It also only supports a couple pre-done layer effects like drap shadows, so you can't specify angles and shadow depth, etc. A few people in this thread have suggested Paint Shop Pro as an alternative to Photoshop. I used to use Paint Shop Pro and it's a great piece of software. I now prefer PSE because Photoshop is more of an industry standard and it's easier for me to just stick with the same interface. I'm a Computing and the Arts student, btw.

Vector graphics:
SodiPodi is a freeware vector-based drawing program. *suggested by ugh*
DrawPlus - Seems to be a semi-popular freeware vector drawing program. *suggested by uethello*

Layout: PagePlus - Seems to be a semi-popular freeware layout program. *suggested by uethello*

Image viewer: Irfanview. I've been using Irfanview for a couple years now. It's very powerful and supports a lot of basic image editing functions. Through plug-ins, you can view just about any media file.
I used to also suggest a program called Slowview, but it has become a commercial program now with only a downloadable trial.

Icon editor - @icon sushi - I've been looking for a good FREEWARE icon editor for the longest time now. Mk4 suggested this in another thread.



IDE's and editors

HTML editor: HTML-Kit. I use HTML-Kit for HTML and PHP editing. It has a built in FTP browser so I can edit files straight from my FTP server. HTML-Kit has tons of features and support for plug-ins to add more features.

WYSIWYG HTML editor: NVU. Finally someone made a standalone version of Mozilla Composer! NVU is excellent for a free WYSIWYG editor.
DHE Editor is another editor that I've found. It uses style sheets to position everything so it doesn't work like regular WYSIWYG editors. It seems to support a lot of optimization and general effects for images too. The interface is really easy to use because you basically "paint" the webpage.

CSS editor: Topstyle Lite. Topstyle Lite is a great CSS editor. It pretty much lets you select CSS properties from lists. I tried the Topstyle Pro HTML editor trial and it's possibly the best HTML/CSS editor I've ever used.

Java IDE: Eclipse. Possibly the coolest IDE I've ever used. Sometimes it has some weird quirks, but it works well for me. Also, Borland's JBuilder 9.0 Personal Edition is free for noncommercial use. There are several other free ones out there. Google for them.

C++ IDE: Dev-C++. It's great and it's free.

Basic (VB) IDE: SharpDevelop. I haven't used this IDE much, but it supports VB.NET. The interface seems pretty similar to that of VB6. It uses the VB.NET SDK which Microsoft provides for free.
xBasic - Never tried it since I have VB6. I heard that it's pretty good.

C# IDE: SharpDevelop. I haven't used it much but it seems to be really cool. It's very similar to Visual Basic 6.0 in the layout.

PHP Editor: phpEDIT - A good PHP editor that not only functions as a text editor but as a relatively loaded IDE. There are a lot of PHP editors but most of them are lacking one thing or another, or aren't being actively updated. phpEDIT seems to be the best all-around editor, too. They also offer a CodeBeauitifer that helps you clean up your code.
Some third party reviews that support the assertion. *Suggested by beer. Comments also by beer.*

Text editor: When it comes to text editors, you're going to get lots of suggestions. Some will suggest the power of Vim or xemacs, others will prefer the simplicity of Notepad+ or Editpad Lite. Personally, I strive for something in between the two. Some discussions on the pros/cons of vim.
*Suggested by beer. Comments also by beer.*

Some good alternatives
Crimson Editor - a generally polished product that is designed for programmers, with syntax highlighting for all sorts of languages. It's very similar to UltraEdit without the nagware or $35 cost. *Suggested by beer. Comments also by beer.*
Scintilla features collapse functions, i.e you can + and - your code, but it isn't a very active project, although it has some nifty features. *Suggested by beer. Comments also by beer.*
JEdit very nice all-round editor, has lots of nifty features, as well as a whole bunch of plugins that can be automatically downloaded and installed using the built in plugin manager. *Suggested by Sunner. Comments also by Sunner*



Audio/Mp3/CD

Audio editor: Audacity. It's a free and simple audio mixer/editor that supports mp3s.

ID3 Tag Editor: The Godfather. It supports freedb search so not only can you search for entire albums, you can also search for individual songs.

Another ID3 Tag Editor: MusicBrainz. This program REALLY helps in organizing thousands of mp3s. You can look up ID3 tags for individual mp3s.

CD/mp3 ripper: CDex or EAC. Search the software forum for mp3 ripping. These two programs seem to be the favorites. (CDex suggested by Elemental007)

Burning software:
ISO's - nsafreak suggests burnatonce. I used to have this program in this post, but it didn't seem to work very well at the time so I removed it. nsafreak reports that it works well for him so give it a try if you need a free ISO burning program!

**General burning - cKGunslinger suggests CD Burner XP.

Audio - Winchester suggests Mp3 Doctor for burning audio CDs. iTunes, recently came out for Windows and, I believe, it supports CD burning and ripping.

** Audio conversion - dbPowerAmp - Suggested by xgi.


System tools

Partition manager: Ranish Partition Manager *Suggested by sciencewhiz *
Boot loader: XOSL *Suggested by sciencewhiz *



Video/Rendering

VideoLAN: VideoLAN - A free opensource DVD decoder! *suggested by Monzie in a thread started by beer *

DVDShrink: DVDShrink - DVD Shrink is software to backup DVD discs. You can use this software in conjunction with DVD burning software of your choice, to make a backup copy of any DVD video disc. *suggested by mr899*

3D everything: Blender3D - Description taken from their website: "open source software for 3D modeling, animation, rendering, post-production, interactive creation and playback." Suggested by CZar.

Modeling and animation: Anim80r - Free 3D modeler and animator written by a guy who works at nVidia. *suggested by uethello*

Morphing software: WinMorph (suggested by hasu)

3D polygon mesh modeler: Wings 3D - "Wings 3D is a polygon mesh modeler inspired by Nendo and Mirai from Izware."

Winchester suggested the following video/3D rendering software:

Maya Personal edition : Nice, but leaves a massive watermark on rendered images. It still has lots of functionality of the full version though!

Gmax: gmax is a free 3D modeling and animation tool based on Discreet's award-winning 3ds max.

Avid FreeDV: Perfect for students, DV camera owners, video enthusiasts or anyone exploring video editing - Avid Free DV software is an easy, free way to join the Avid family and test-drive the industry-standard editing interface used by more professionals than any other video editing solution. This version is a Vietnam POW camp diet version compared to the full version, but hey it works.
DopeFiend's review of Avid FreeDV - "Yes, it's free and that's great. However, I tried to import some large (~16Gb) DV files into it that I'm working on, and it told me that it only supports .jpg and .mov imports. Plus, the interface goes to pot on a dual-screen setup; the program maximises itself to the width of both screens (grr) and all the palettes become corrupted."

(copied from http://forums.anandtech.com/messageview.aspx?catid=33&threadid=997283&enterthread=y)

Canon EOS Digital

Canon EOS-1Ds MarkII Digital Camera for professionals
16.7Megapixel!!

http://www.eos-d-slr.net/1ds_mark2.html
http://eos-d.axisz.jp/pict/1ds_mark2/1Ds-1sum.jpg
http://eos-d.axisz.jp/pict/1ds_mark2/1Ds-2sum.jpg