<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Soul Of Free Loop &#187; 脚本</title>
	<atom:link href="https://zohead.com/archives/tag/script/feed/" rel="self" type="application/rss+xml" />
	<link>https://zohead.com</link>
	<description>Uranus Zhou&#039;s Blog</description>
	<lastBuildDate>Sat, 19 Jul 2025 15:42:46 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.8</generator>
	<item>
		<title>使用AutoIt导出QQ群漫游聊天记录</title>
		<link>https://zohead.com/archives/autoit-export-qqmsg/</link>
		<comments>https://zohead.com/archives/autoit-export-qqmsg/#comments</comments>
		<pubDate>Tue, 08 Apr 2014 14:52:41 +0000</pubDate>
		<dc:creator><![CDATA[Uranus Zhou]]></dc:creator>
				<category><![CDATA[工具]]></category>
		<category><![CDATA[技术]]></category>
		<category><![CDATA[AutoIt]]></category>
		<category><![CDATA[QQ]]></category>
		<category><![CDATA[脚本]]></category>

		<guid isPermaLink="false">http://zohead.com/?p=694</guid>
		<description><![CDATA[本文同步自（最佳显示效果请点击）：https://zohead.com/archives/autoit-export-qqmsg/ 近日需要将某个QQ群的聊天记录导出来查找需要的东西，但发现本地保存的聊天记录比较少，很多日志都在漫游的聊天记录里，QQ本身又没有提供直接导出漫游聊天记录的功能，因此就想到写一个 AutoIt 自动脚本来模拟鼠标和键盘动作自动导出日志了。 首先安装 AutoIt v3，然后打开需要导出的QQ群聊天窗口，点击 “消息记录” 按钮（消息会显示在右边窗口），然后切换到 “漫游消息” 标签；接着再开启一个空的 EditPlus 文档： 然后运行我写的这个简单的 copy_q [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>本文同步自（最佳显示效果请点击）：<a href="https://zohead.com/archives/autoit-export-qqmsg/" target="_blank">https://zohead.com/archives/autoit-export-qqmsg/</a></p>
<p>近日需要将某个QQ群的聊天记录导出来查找需要的东西，但发现本地保存的聊天记录比较少，很多日志都在漫游的聊天记录里，QQ本身又没有提供直接导出漫游聊天记录的功能，因此就想到写一个 AutoIt 自动脚本来模拟鼠标和键盘动作自动导出日志了。</p>
<p>首先安装 AutoIt v3，然后打开需要导出的QQ群聊天窗口，点击 “消息记录” 按钮（消息会显示在右边窗口），然后切换到 “漫游消息” 标签；接着再开启一个空的 EditPlus 文档：</p>
<div style="width: 650px" class="wp-caption alignnone"><a href="http://zohead.com/wp-content/uploads/qq-remote-msg.jpg" target="_blank"><img alt="QQ群漫游聊天记录" src="http://zohead.com/wp-content/uploads/qq-remote-msg.jpg" width="640" height="437" /></a><p class="wp-caption-text">QQ群漫游聊天记录</p></div>
<p>然后运行我写的这个简单的 <strong>copy_qqmsg.au3</strong> AutoIt 脚本就可以自动将漫游聊天记录复制到 EditPlus 中了，运行之前请先将第一行的 qqgroup 换成实际的QQ群或者聊天窗口的名字。</p>
<p>AutoIt 脚本内容其实非常简陋的，没有什么难度，内容如下：</p>
<pre class="brush: bash; highlight: [5,14]; title: copy_qqmsg.au3; notranslate">
Local $hWnd = WinGetHandle(&quot;[CLASS:TXGuiFoundation; TITLE:qqgroup]&quot;, &quot;&quot;)
Local $editWnd = WinGetHandle(&quot;EditPlus&quot;, &quot;&quot;)

$i=1
While $i&lt;=200
	WinActivate($hWnd)
	Local $aPos = WinGetPos(&quot;[ACTIVE]&quot;)
	MouseClick(&quot;left&quot;, $aPos[0] + $aPos[2] - 52, $aPos[1] + $aPos[3] - 18)
	Sleep(100)
	$i=$i+1
WEnd

$i=1
While $i&lt;=100
	WinActivate($hWnd)
	Local $aPos = WinGetPos(&quot;[ACTIVE]&quot;)
	MouseClick(&quot;left&quot;, $aPos[0] + $aPos[2] - 52, $aPos[1] + $aPos[3] - 18)
	Sleep(5000)
	Send(&quot;^a&quot;)
	Send(&quot;^c&quot;)
	WinActivate($editWnd)
	Sleep(500)
	Send(&quot;^v&quot;)
	Send(&quot;{ENTER}&quot;)
	Sleep(500)
	$i=$i+1
WEnd
</pre>
<p>先根据QQ聊天窗口类名（TXGuiFoundation）和标题名称（根据实际需要修改）查找到QQ聊天窗口句柄，再查找到 EditPlus 窗口句柄，接着将鼠标移动到QQ聊天窗口右下角的 “&lt;” 上一页按钮上自动点击并发送全选及复制按键，然后切换到 EditPlus 窗口中进行粘贴。程序运行过程中鼠标和键盘不要乱按哦。</p>
<p>第一个循环中的 200 表示当前页再往前翻多少页，第二个循环中的 100 表示自动拷贝多少页的聊天记录（方式比较土，没什么好办法判断什么时候结束）。鼠标点击之后的 Sleep 5秒钟是为了给QQ显示漫游聊天记录的时间。</p>
<p>需要的朋友可以到我的 Gist 上下载此 AutoIt 脚本，可以自己下载之后用 AutoIt 编译成可执行程序的：</p>
<p><a href="http://gist.github.com/zohead/10130455" target="_blank">http://gist.github.com/zohead/10130455</a></p>
<p>有任何问题的话欢迎交流哦~~~</p>
]]></content:encoded>
			<wfw:commentRss>https://zohead.com/archives/autoit-export-qqmsg/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript脚本实现随手记商家自动排序</title>
		<link>https://zohead.com/archives/sort-feidee-store/</link>
		<comments>https://zohead.com/archives/sort-feidee-store/#comments</comments>
		<pubDate>Sat, 31 Aug 2013 17:00:21 +0000</pubDate>
		<dc:creator><![CDATA[Uranus Zhou]]></dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[工具]]></category>
		<category><![CDATA[技术]]></category>
		<category><![CDATA[财务]]></category>
		<category><![CDATA[商家]]></category>
		<category><![CDATA[排序]]></category>
		<category><![CDATA[浏览器]]></category>
		<category><![CDATA[脚本]]></category>
		<category><![CDATA[随手记]]></category>

		<guid isPermaLink="false">http://zohead.com/?p=513</guid>
		<description><![CDATA[随手记商家显示问题 最近将手机上的记账软件由 EasyMoney 更换为随手记之后，在使用随手记时发现随手记的商家分类功能在实际记账时非常不方便。记账时选择商家只有 “最近商家” 和 “所有商家” 这两个选项，但这里面的所有商家列表是按商家分类添加的顺序排列的，而不是按商家的名称排序的，这样选择起来就非常困难。虽然随手记支持通过安装其它 App 识别当前位置旁边的商家，但小的商家往往无法识别，而且有时是消费完了过段时间才记账，并不特别实用。 看一张随手记上的商家列表图片： 像我的情况一共有将近 300 个商家，如果要在这个长长得未排序的商家列表里找到我需要的商家，还是比较麻烦的。随手记在 We [&#8230;]]]></description>
				<content:encoded><![CDATA[<h2>随手记商家显示问题</h2>
<p>最近将手机上的记账软件由 EasyMoney 更换为随手记之后，在使用随手记时发现随手记的商家分类功能在实际记账时非常不方便。记账时选择商家只有 “最近商家” 和 “所有商家” 这两个选项，但这里面的所有商家列表是按商家分类添加的顺序排列的，而不是按商家的名称排序的，这样选择起来就非常困难。虽然随手记支持通过安装其它 App 识别当前位置旁边的商家，但小的商家往往无法识别，而且有时是消费完了过段时间才记账，并不特别实用。</p>
<p>看一张随手记上的商家列表图片：</p>
<p><a href="https://zohead.com/wp-content/uploads/feidee-store-category.jpg"><img title="未排序的随手记商家列表" alt="未排序的随手记商家列表" src="https://zohead.com/wp-content/uploads/feidee-store-category.jpg" width="483" height="231" /></a></p>
<p>像我的情况一共有将近 300 个商家，如果要在这个长长得未排序的商家列表里找到我需要的商家，还是比较麻烦的。随手记在 Web 版的设置界面中支持调整商家的位置，而且只能支持在某一个商家上点向上、向下按钮调整位置，不支持拖动，就算支持拖动，对于将近 300 个商家的情况，如果要一一拖动让所有商家按名称来排序还是极其痛苦的。</p>
<h2>JavaScript 对商家排序</h2>
<p>为此我专门用浏览器调试工具研究了下调整商家位置的请求，发现调整位置时提交的数据实际是所有商家在一起的，这样就好办了，我写了一段 JavaScript 脚本用于在浏览器上直接自动按名称排序（数字在前，英文次之，然后是中文按拼音排序）所有商家。</p>
<p>首先使用 IE9 或以上的浏览器（脚本要求，不要使用 360、搜狗之类的浏览器防止脚本运行有问题，嘿嘿）访问随手记的 Web 版，进入设置 - 分类设置 - 商家分类，也就是这个地址：<a href="https://money07.feidee.com/money/category/storeCategory.do" target="_blank">https://money07.feidee.com/money/category/storeCategory.do</a>，在这个页面上你可以看到所有商家的列表。</p>
<p>然后拷贝下面这一段 JavaScript 代码粘贴到浏览器地址栏中，注意这里只有一行，必须整行全部拷贝下来：</p>
<pre class="brush: plain; title: ; notranslate">
javascript:rows = document.getElementsByClassName(&quot;lb-row&quot;); var shops = []; var shids = []; var re = /^category\d+$/; for (var i = 0; i &lt; rows.length; i++) { if (re.test(rows[i].id)) { var t = rows[i].getElementsByClassName(&quot;li-level2&quot;); if (t.length &gt; 0) { shops.push(t[0].innerHTML); shids[t[0].innerHTML] = rows[i].id.substr(8); } } } shops.sort(function(a,b){return a.localeCompare(b)}); pstr = &quot;&quot;; for (i = 0; i &lt; shops.length; i++) { if (i &gt; 0) { pstr += &quot;-&quot;; } pstr += shids[shops[i]]; } var p = document.createElement(&quot;DIV&quot;); p.innerHTML = &quot;&lt;form name='frm' method='post' action='/money/category/storeCategory.rmi'&gt;&lt;input type='hidden' name='m' value='updateOrder'/&gt;&lt;input type='hidden' name='idList' value='&quot; + pstr + &quot;'/&gt;&lt;/form&gt;&quot;; document.body.appendChild(p); document.frm.submit(); void(0)
</pre>
<p>特别需要注意的是拷贝到 IE 浏览器的地址上你可能会发现前面少了 <code>javascript:</code> 这个前缀，这时必须你手工把 <code>javascript:</code> 这个前缀补到地址的最前面（这一步不可缺少），如下图所示：</p>
<p><a href="https://zohead.com/wp-content/uploads/feidee-store-sort-js.jpg"><img title="随手记自动排序脚本" alt="随手记自动排序脚本" src="https://zohead.com/wp-content/uploads/feidee-store-sort-js.jpg" width="484" height="156" /></a></p>
<p>然后在地址栏上按下回车键，脚本就会自动执行，并且返回一个空白的网页，这一般表示执行成功了。接着可以点击浏览器后退按钮回到商家分类页面看看执行的成果：</p>
<p><a href="https://zohead.com/wp-content/uploads/feidee-sorted-store.jpg"><img title="已排序的随手记商家列表" alt="已排序的随手记商家列表" src="https://zohead.com/wp-content/uploads/feidee-sorted-store.jpg" width="442" height="371" /></a></p>
<p>可以看到商家被已经自动按名称来排序了，接着只要在手机或者平板上同步一下就可以正常使用了，必须比随手记默认的坑爹商家排序好多了。</p>
<h2>代码解析</h2>
<p>对 Web 开发比较熟悉的同学应该比较熟悉下面的原始 JavaScript 代码哈，直接使用 JS 自带的 localeCompare 函数进行字符串排序：</p>
<pre class="brush: jscript; title: sort-feidee-store.js; notranslate">
rows = document.getElementsByClassName(&quot;lb-row&quot;);

var shops = [];
var shids = [];
var re = /^category\d+$/;

for (var i = 0; i &lt; rows.length; i++) {
	if (re.test(rows[i].id)) {
		var t = rows[i].getElementsByClassName(&quot;li-level2&quot;);
		if (t.length &gt; 0) {
			shops.push(t[0].innerHTML);
			shids[t[0].innerHTML] = rows[i].id.substr(8);
		}
	}
}

shops.sort(function(a,b){ return a.localeCompare(b)});

pstr = &quot;&quot;;
for (i = 0; i &lt; shops.length; i++) {
	if (i &gt; 0) {
		pstr += &quot;-&quot;;
	}
	pstr += shids[shops[i]];
}

var p = document.createElement(&quot;DIV&quot;);
p.innerHTML = &quot;&lt;form name='frm' method='post' action='/money/category/storeCategory.rmi'&gt;&lt;input type='hidden' name='m' value='updateOrder'/&gt;&lt;input type='hidden' name='idList' value='&quot; + pstr + &quot;'/&gt;&lt;/form&gt;&quot;;
document.body.appendChild(p);
document.frm.submit();
</pre>
<p>以上脚本和修改为个人经验，如有任何问题欢迎提出指正哦，玩的开心~~~ ^_^</p>
]]></content:encoded>
			<wfw:commentRss>https://zohead.com/archives/sort-feidee-store/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>EasyMoney财务数据迁移到随手记的流程</title>
		<link>https://zohead.com/archives/easymoney-to-feidee/</link>
		<comments>https://zohead.com/archives/easymoney-to-feidee/#comments</comments>
		<pubDate>Wed, 21 Aug 2013 16:33:01 +0000</pubDate>
		<dc:creator><![CDATA[Uranus Zhou]]></dc:creator>
				<category><![CDATA[shell]]></category>
		<category><![CDATA[技术]]></category>
		<category><![CDATA[财务]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[CSV]]></category>
		<category><![CDATA[EasyMoney]]></category>
		<category><![CDATA[easymoney2feidee]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[同步]]></category>
		<category><![CDATA[报表]]></category>
		<category><![CDATA[脚本]]></category>
		<category><![CDATA[迁移]]></category>
		<category><![CDATA[随手记]]></category>

		<guid isPermaLink="false">http://zohead.com/?p=484</guid>
		<description><![CDATA[关于 EasyMoney 记账软件 之前在 Android 手机一直都用一个比较小巧的记账软件 Handy EasyMoney（轻松理财） 来记录管理平时的理财开销等数据，虽然这个 App 也比较流畅好用，但用到后来越来越发现 EasyMoney 的缺点： 只支持 Android 平台，不支持 iOS、Windows 等平台； 完全不支持网络，没有同步、Web 管理等操作，更别想实现全平台同步等目标了； 老版本导出的数据有可能导入不了新版本，有点不保险； 条件查询、报表管理功能还比较薄弱； 采用私有的数据格式，导出只能再选择 CSV 格式导出，不方便迁移到其它软件； 不支持导入其它财务软件的数 [&#8230;]]]></description>
				<content:encoded><![CDATA[<h2>关于 EasyMoney 记账软件</h2>
<p>之前在 Android 手机一直都用一个比较小巧的记账软件 Handy EasyMoney（轻松理财） 来记录管理平时的理财开销等数据，虽然这个 App 也比较流畅好用，但用到后来越来越发现 EasyMoney 的缺点：</p>
<ul>
<li>只支持 Android 平台，不支持 iOS、Windows 等平台；</li>
<li>完全不支持网络，没有同步、Web 管理等操作，更别想实现全平台同步等目标了；</li>
<li>老版本导出的数据有可能导入不了新版本，有点不保险；</li>
<li>条件查询、报表管理功能还比较薄弱；</li>
<li>采用私有的数据格式，导出只能再选择 CSV 格式导出，不方便迁移到其它软件；</li>
<li>不支持导入其它财务软件的数据。</li>
</ul>
<p>而最近看到的随手记软件（官网：<a href="http://www.feidee.com/" target="_blank">http://www.feidee.com/</a>）则基本都解决了上面的问题，特别是全平台同步（不止主流的 Android、iPhone、iPad 等平台，连软件现在很稀少的 Windows Store 上都有随手记了）和强大的 Web 管理功能还是有比较深的印象。</p>
<p>最近想着能把数据从 EasyMoney 迁移到随手记，但由于 EasyMoney 并不是特别知名，随手记支持的数据导入方式并没有 EasyMoney，而我在 EasyMoney 上已经记了一年多的财务数据，如果手工导入是会疯掉的。因此稍研究了下 EasyMoney 的 CSV 导出数据格式和随手记的 Web 导入格式，写了一个脚本来自动实现数据转换，方便进行导入。</p>
<h2>EasyMoney 数据导入随手记</h2>
<p>下面以我现在使用的 Handy EasyMoney 1.6.3 汉化版本为例子说明如何将 EasyMoney 财务数据导入到随手记中，英文版的 EasyMoney 的方法需要稍做下改动，请注意下面的说明。</p>
<p>首先进入手机的 EasyMoney App，记下随手记里的各个账户的名称和初始余额，例如我的账户列表为（名称不可出错）：<strong>现金</strong>、<strong>信用卡</strong>、<strong>银行账户</strong>、<strong>支付宝</strong>。然后点击菜单中的“数据库工具”，选择“导出.CSV”，然后就可以选择不同的账户类型进行导出，建议将“字段分隔符”设置为“|”或者“Tab”，防止和财务数据中的信息冲突 ：</p>
<p><a href="https://zohead.com/wp-content/uploads/easymoney-export-csv.jpg"><img title="EasyMoney导出CSV数据" alt="EasyMoney导出CSV数据" src="https://zohead.com/wp-content/uploads/easymoney-export-csv.jpg" width="219" height="246" /></a></p>
<p>点击“导出”按钮就会在 SD 卡的 EasyMoney/csv_output 文件夹中产生对应的 CSV 文件，将 CSV 文件拷贝到 PC 中，可以用支持 UTF-8 的文本编辑器打开检查下，格式就像下面这样：</p>
<pre class="brush: plain; title: 现金_cny.csv; notranslate">
PAYEE_ITEM_DESC|CATEGORY|AMOUNT|STATUS|TRAN_DATE|REMARKS
&quot;上海汽车站&quot;|&quot;交通&quot;|-42.00|&quot;未清算&quot;|&quot;21 Aug 2013&quot;|&quot;回常熟汽车票&quot;|
&quot;常熟公交&quot;|&quot;交通&quot;|-1.00|&quot;未清算&quot;|&quot;21 Aug 2013&quot;|&quot;汽车南站回公司&quot;|
&quot;银环面馆&quot;|&quot;食品&quot;|-8.00|&quot;未清算&quot;|&quot;21 Aug 2013&quot;|&quot;午餐&quot;|
&quot;华兴便利&quot;|&quot;食品&quot;|-1.50|&quot;未清算&quot;|&quot;21 Aug 2013&quot;|&quot;中午雪糕&quot;|
&quot;安徽大排档&quot;|&quot;食品&quot;|-8.00|&quot;未清算&quot;|&quot;21 Aug 2013&quot;|&quot;晚餐&quot;|
&quot;华联超市&quot;|&quot;购物&quot;|-13.60|&quot;未清算&quot;|&quot;21 Aug 2013&quot;|&quot;瑞士卷、山楂、雪碧、牙膏&quot;|
</pre>
<p>下面先访问<a href="http://www.feidee.com/" target="_blank">随手记官方网站</a>，进入 “我的账本”，点击 “账户” 标签，向随手记的账户列表预先添加好需要的账户以备导入，账户列表里的账户名称最好与 EasyMoney 中的账户名称一致，这样批量导入数据比较方便（可以等导入完成之后修改账户名称的）。</p>
<p>例如如下图所示，我把现金账户中的子账户名称改为与 EasyMoney 对应的名称：<strong>现金</strong>，并设置初始余额，将信用卡账户中的子账户名称改为：<strong>信用卡</strong>，将金融账户中的子账户名称改为：<strong>银行账户</strong>，并在虚拟账户中建立一个账户，名称为：<strong>支付宝</strong>。</p>
<p><a href="https://zohead.com/wp-content/uploads/efeidee-account-list.jpg"><img title="随手记账户列表" alt="随手记账户列表" src="https://zohead.com/wp-content/uploads/feidee-account-list.jpg" width="428" height="306" /></a></p>
<p>需注意的是 EasyMoney 中信用卡账户与普通账户没什么区别，初始余额表示信用卡的初始可用额度，例如 10000 元的信用卡初始余额为 8000 元；而在随手记中初始余额表示信用卡的负债数额，这样上面的情况就可以用随手记专门的“信用卡”功能模块，先设置信用卡可用额度为 10000 元，初始负载数额为 2000 元。</p>
<p>随后进入随手记 Web 版的 “记账” 标签，这时就有几条记录表示余额变更，此时需要将这几条记录的时间修改为 EasyMoney 中最早的记录时间之前，这样导入数据之后账户的余额就是正确的值。</p>
<p>下载导入数据用的随手记 Web 版 Excel 模板（点击 [<a href="http://money.feidee.com/u07/downloadDoc/template.xls" target="_blank">这里</a>] 下载），打开查看一下随手记的数据格式如下所示：</p>
<p><a href="https://zohead.com/wp-content/uploads/feidee-template.jpg"><img title="随手记数据格式" alt="随手记数据格式" src="https://zohead.com/wp-content/uploads/feidee-template.jpg" width="585" height="122" /></a></p>
<p>简单研究了随手记的 Excel 模板格式之后，我写了一个 Linux shell 环境（Windows 上也可以使用 Cygwin 等 shell 环境）下运行的 easymoney2feidee.sh 脚本来自动将 EasyMoney 导出的数据转换为随手记的数据格式。</p>
<p>你可以直接点击 [<a href="http://0paste.com/528.txt" target="_blank">这里</a>] 或 [<a href="http://paste.ubuntu.com/6010802/" target="_blank">这里</a>] 下载此脚本，脚本内容如下：</p>
<pre class="brush: bash; title: easymoney2feidee.sh; notranslate">
#!/bin/sh
if [ $# -lt 3 ]; then
echo &quot;Usage: $0 csv-file account-type out-file&quot;
exit
fi

EM_FILE=&quot;$1&quot;
EM_TYPE=&quot;$2&quot;
EM_OUT=&quot;$3&quot;

sed -i 's/\&quot;//g' $EM_FILE

gawk -F '|' -v ETYPE=&quot;$EM_TYPE&quot; 'BEGIN{
m = split(&quot;Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec&quot;, d, &quot;|&quot;)
for (o = 1; o &lt;= m; o++){
months[d[o]] = sprintf(&quot;%02d&quot;, o)
}
}
{
if (NR &gt; 1 &amp;&amp; $2 != &quot;转账 (转入)&quot;) {
OUT_TYPE = &quot;&quot;;
OUT_VAL = $3;
if ($2 == &quot;转账 (转出)&quot;) {
if (substr($1, 1, 13) == &quot;转入账户 &quot;) {
OUT_TYPE = substr($1, 14);
}
printf &quot;转账&quot;;
} else if ($3 &gt; 0) {
printf &quot;收入&quot;;
} else {
printf &quot;支出&quot;;
}
if ($3 &lt; 0) {
OUT_VAL = -OUT_VAL;
}
split($5, time, &quot; &quot;);
date = time[3]&quot; &quot;months[time[2]]&quot; &quot;time[1]&quot; 0 0 0&quot;
printf &quot;\t&quot;strftime(&quot;%Y-%m-%d&quot;, mktime(date));
if (length(OUT_TYPE) &lt;= 0) {
printf &quot;\t&quot;$2;
} else {
printf &quot;\t&quot;;
}
printf &quot;\t&quot;;
printf &quot;\t&quot;ETYPE;
printf &quot;\t&quot;OUT_TYPE;
printf &quot;\t&quot;OUT_VAL;
printf &quot;\t本人&quot;;
if (length(OUT_TYPE) &lt;= 0) {
printf &quot;\t&quot;$1;
} else {
printf &quot;\t&quot;;
}
printf &quot;\t&quot;;
printf &quot;\t&quot;$6&quot;\n&quot;;
}
}' $EM_FILE &gt; $EM_OUT
</pre>
<p>下面简单说明下脚本：</p>
<p>在 shell 下运行 easymoney2feidee.sh 脚本并传入 3 个参数，分别表示 EasyMoney CSV 文件名、CSV 文件对应的账户名称、输出文件名称。</p>
<p>如果你的 CSV 文件不是用 “|” 隔开的，请修改脚本第 13 行中的 “|” 分隔符。脚本首先会去掉 CSV 文件中的所有双引号方便处理数据，然后按分割符得到数据，并判断是否是 EasyMoney 的转账处理（转出需要分别记录本账户名称、转入的账户名称；如果是转入则不需要记录），先记录财务记录类型，然后将 EasyMoney 的日期（EasyMoney 只支持日期，没有细化到具体时间）转换为随手记的时间格式，记录商家、金额（EasyMoney 金额为正值表示收入，负值表示支出）等信息，最终以 Tab 隔开生成输出文件（Tab 隔开的文本复制到随手记 Excel 表格中时可以自动跨越列）。</p>
<p>需要注意的是此脚本处理的是汉化版的 EasyMoney 的数据，其中转账用的固定值为：<strong>转账 (转入)</strong>、<strong>转账 (转出)</strong>、<strong>转入账户</strong>，如果你使用的是英文原版的 EasyMoney App，那需要将脚本小做下修改。</p>
<p>例如我在 Cygwin 环境下运行脚本将 “现金” 账户的 CSV 文件转为随手记的数据：</p>
<p>./easymoney2feidee.sh <strong>现金_cny.csv</strong> <strong>现金</strong> <strong>现金.txt</strong></p>
<p>输出的文件即为：<strong>现金.txt</strong> 文件，使用文本编辑器打开 <strong>现金.txt</strong> 文件，并将所有内容复制到随手记的模板 Excel 文件中并保存，最终数据形式即符合随手记的要求了（检查下与 EasyMoney 的 CSV 数据是否相符）：</p>
<p><a href="https://zohead.com/wp-content/uploads/feidee-data.jpg"><img title="导入的随手记数据" alt="导入的随手记数据" src="https://zohead.com/wp-content/uploads/feidee-data.jpg" width="608" height="106" /></a></p>
<p>然后就可以到随手记的 “我的账本” 首页中选择 “导入导出” 并选择数据导入选项的 “随手记web版”，选择上面生成的 Excel 文件，点击 “上传数据” 等待片刻，随手记就能识别到数据，此时还需要最后一步选择分类数据和随手记账户：</p>
<p><a href="https://zohead.com/wp-content/uploads/feidee-import.jpg"><img title="导入随手记数据" alt="导入随手记数据" src="https://zohead.com/wp-content/uploads/feidee-import.jpg" width="614" height="381" /></a></p>
<p>如上图所示，仔细选择 EasyMoney 中的分类和随手记分类的对应关系，并选择导入的随手记账户，点击导入数据按钮，稍等几分钟数据就正确导入了（我的现金账户 2000 条数据导入花了 4 分钟左右），在随手记 Web 版的记账界面中可以查看到：</p>
<p><a href="https://zohead.com/wp-content/uploads/feidee-view-data.jpg"><img title="成功导入的数据" alt="成功导入的数据" src="https://zohead.com/wp-content/uploads/feidee-view-data.jpg" width="594" height="130" /></a></p>
<p>如果你发现刚才选择的分类有的条目不对应，完全可以借助随手记强大的条件查询功能先搜索到对应条目，然后使用批量修改功能统一进行修改，总之比 EasyMoney 的可用性好不少。</p>
<p>本文为个人总结经验所得，所写的脚本并不适合所有的情况，因此使用中有任何问题欢迎提出指正哦，玩的开心~~~ ^_^</p>
]]></content:encoded>
			<wfw:commentRss>https://zohead.com/archives/easymoney-to-feidee/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Symantec备份软件独立磁带驱动集</title>
		<link>https://zohead.com/archives/symantec-tape-driver/</link>
		<comments>https://zohead.com/archives/symantec-tape-driver/#comments</comments>
		<pubDate>Thu, 16 Aug 2012 16:47:24 +0000</pubDate>
		<dc:creator><![CDATA[Uranus Zhou]]></dc:creator>
				<category><![CDATA[存储]]></category>
		<category><![CDATA[工具]]></category>
		<category><![CDATA[Backup Exec]]></category>
		<category><![CDATA[NetBackup]]></category>
		<category><![CDATA[Symantec]]></category>
		<category><![CDATA[磁带]]></category>
		<category><![CDATA[脚本]]></category>
		<category><![CDATA[解压缩]]></category>
		<category><![CDATA[驱动]]></category>

		<guid isPermaLink="false">http://zohead.com/?p=296</guid>
		<description><![CDATA[本文同步自（最佳显示效果请点击）：https://zohead.com/archives/symantec-tape-driver/ 最近需要使用 Symantec Backup Exec、NetBackup 等备份软件测试磁带库，而且 Backup Exec 中已经自带了很多的磁带和磁带库的驱动，但是这些驱动没法独立出来用。特别是在新的 Windows 系统上，如果 Backup Exec 备份软件无法安装，而又找不到磁带驱动，这时就需要专门的 Symantec 的磁带驱动集了。 Symantec 官方网站上有最新版本的 Tape Device Drivers 更新程序，例如： http:/ [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>本文同步自（最佳显示效果请点击）：<a href="https://zohead.com/archives/symantec-tape-driver/" target="_blank">https://zohead.com/archives/symantec-tape-driver/</a></p>
<p>最近需要使用 Symantec Backup Exec、NetBackup 等备份软件测试磁带库，而且 Backup Exec 中已经自带了很多的磁带和磁带库的驱动，但是这些驱动没法独立出来用。特别是在新的 Windows 系统上，如果 Backup Exec 备份软件无法安装，而又找不到磁带驱动，这时就需要专门的 Symantec 的磁带驱动集了。</p>
<p>Symantec 官方网站上有最新版本的 Tape Device Drivers 更新程序，例如：</p>
<p><a href="http://www.symantec.com/business/support/index?page=content&amp;id=TECH173790" target="_blank">http://www.symantec.com/business/support/index?page=content&amp;id=TECH173790</a></p>
<p>这个是 Symantec Backup Exec 2010 R3 版本的最新磁带驱动集。</p>
<p>下载之后，你会发现这个更新程序必须在安装了其对应版本的备份软件之后才能运行，不同远程安装到别的机器上，这多少显得非常不便。为此我从 Symantec 官网最新版本的 Tape Device Drivers 程序中导出了所有的驱动和安装程序并打包，此包可以在没有安装 Symantec 软件的情况下，通过设备管理器直接找到解压缩的目录进行磁带驱动安装。如果安装了 Symantec 备份软件，你也可以直接用包中的 tapeinst.exe 程序自动安装更新磁带的驱动。</p>
<p>做这个驱动集合包的步骤也很简单，解压缩 Symantec 安装程序，然后从中得到 Data.cab 之类的压缩包并解压缩（新版本的安装程序中可能是 msp 类型的数据文件，可以用 Universal Extractor 之类的软件进行解压）。解压缩之后会看到一堆文件名很长的文件，例如：F1078_testfile.sy_.1B15BB01_8E2D_4A12_A3E6_175864F3EF67。</p>
<p>实际上这种长的文件是压缩过的驱动程序（原文件名：testfile.sys），只不过文件名上加了点处理，为此我写了个非常简单的脚本进行自动遍历文件并解压缩：</p>
<pre class="brush: bash; highlight: [10,12,43,44,47]; title: extract-symantec-driver; notranslate">
#!/bin/sh
# extract symantec tape device drivers from its MSI file
# file name form: F1078_testfile.sy_.1B15BB01_8E2D_4A12_A3E6_175864F3EF67&quot;

IND=&quot;tapedrvs&quot;
mkdir $IND

for j in `ls *`; do
	# get real file name in full file name
	ONAME=`echo $j | awk '{print substr($0,7,length($0)-43);}'`
	# determine whether file is compressed
	EXNAME=`echo $ONAME 2&gt;/dev/null | awk -F &quot;.&quot; '{if (substr($0,length($0),1)==&quot;_&quot; &amp;&amp; NF&gt;1) {print $NF;}}' 2&gt;/dev/null`

	if [ &quot;x$ONAME&quot; = &quot;x&quot; ]; then
		continue
	fi

	if [ &quot;x$EXNAME&quot; != &quot;x&quot; ]; then
		# try to fix prefix name for some common file types
		NNM=&quot;&quot;
		if [ $EXNAME = &quot;CF_&quot; ]; then
			NNM=&quot;CFG&quot;
		elif [ $EXNAME = &quot;cf_&quot; ]; then
			NNM=&quot;cfg&quot;
		elif [ $EXNAME = &quot;dl_&quot; ]; then
			NNM=&quot;dll&quot;
		elif [ $EXNAME = &quot;ex_&quot; ]; then
			NNM=&quot;exe&quot;
		elif [ $EXNAME = &quot;in_&quot; ]; then
			NNM=&quot;inf&quot;
		elif [ $EXNAME = &quot;sy_&quot; ]; then
			NNM=&quot;sys&quot;
		elif [ $EXNAME = &quot;tt_&quot; ]; then
			NNM=&quot;ttf&quot;
		elif [ $EXNAME = &quot;vs_&quot; ]; then
			NNM=&quot;vsd&quot;
		fi

		if [ -z &quot;$NNM&quot; ]; then
			echo &quot;Unknown prefix of $ONAME in $j&quot;
		else
			# use expand to extract file
			NNM=`echo $ONAME | sed 's/'$EXNAME'$/'$NNM'/g'`
			expand $j $IND/$NNM
		fi
	else
		cp $j $IND/$ONAME
	fi
done
</pre>
<p>这个脚本用到了 Windows 下的命令，因此需要在 Windows 下通过 Mingw 或者 Cygwin 之类的类 Linux shell 环境来运行。此脚本已在 Symantec 几个不同版本的 Backup Exec、NetBackup 备份软件的 Tape Device Drivers 包下验证过。</p>
<p>脚本会自动判断遍历到的文件是否是压缩的（压缩的文件扩展名名是以下划线结尾的，例如 <strong>test.exe</strong> 压缩后变为 <strong>test.ex_</strong>），如果是压缩的，则尝试自动修改后缀名，并通过 Windows 自带的 expand 命令将压缩的文件解压缩到指定的目录中（压缩的文件名 [<strong>test.ex_</strong>] 变换为正常的文件名 [<strong>test.exe</strong>]），如果没有识别到压缩文件类型，脚本会将压缩文件名和上面的完整文件名打印输出方便用户手工处理。如果遍历到的文件不是压缩的，那直接拷贝到指定的目录中（文件名也变换为正常的文件名）。</p>
<p>我已经打包好的 Symantec 磁带驱动集可以在这里下载：</p>
<p><a href="http://miseal.googlecode.com/files/symantec-tape-drv-v1.0.7z" target="_blank">http://miseal.googlecode.com/files/symantec-tape-drv-v1.0.7z</a></p>
<p>PS：</p>
<p>如果有的磁带未找到驱动，但确认 Symantec 可以支持，你可以自己修改解压缩出来的 vrtstape.inf 配置文件将自己的磁带设备信息加进入。另外 extract-symantec-driver 脚本也已经在压缩包中。这个驱动集主要是方便自己测试使用的，如果有任何问题欢迎指正哦。</p>
]]></content:encoded>
			<wfw:commentRss>https://zohead.com/archives/symantec-tape-driver/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
