<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Trash files from the OS X command line</title>
	<atom:link href="http://hasseg.org/blog/post/406/trash-files-from-the-os-x-command-line/feed/" rel="self" type="application/rss+xml" />
	<link>http://hasseg.org/blog/post/406/trash-files-from-the-os-x-command-line/</link>
	<description></description>
	<lastBuildDate>Fri, 04 May 2012 16:38:56 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: Ali Rantakari</title>
		<link>http://hasseg.org/blog/post/406/trash-files-from-the-os-x-command-line/comment-page-1/#comment-5934</link>
		<dc:creator>Ali Rantakari</dc:creator>
		<pubDate>Sun, 22 Jan 2012 17:58:53 +0000</pubDate>
		<guid isPermaLink="false">http://hasseg.org/blog/?p=406#comment-5934</guid>
		<description>Hi Thomas,

Thanks for the feedback; I&#039;ll try to make the usage output more clear in the next version, and the lack of recursive file size calculation is definitely an issue I need to address.</description>
		<content:encoded><![CDATA[<p><span class='eg-image' style='float:left; margin-right:10px; display:block; width:40px' ><a rel='external nofollow' href='http://hasseg.org'><img alt='' src='http://1.gravatar.com/avatar/d15666558763fe2deffd703eeff36761?s=40&amp;d=http%3A%2F%2Fhasseg.org%2Fblank-avatar.png%3Fs%3D40&amp;r=G' class='avatar avatar-40 photo' height='40' width='40' /></a></span>Hi Thomas,</p>
<p>Thanks for the feedback; I&#8217;ll try to make the usage output more clear in the next version, and the lack of recursive file size calculation is definitely an issue I need to address.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thomas Rose</title>
		<link>http://hasseg.org/blog/post/406/trash-files-from-the-os-x-command-line/comment-page-1/#comment-5933</link>
		<dc:creator>Thomas Rose</dc:creator>
		<pubDate>Wed, 18 Jan 2012 20:55:38 +0000</pubDate>
		<guid isPermaLink="false">http://hasseg.org/blog/?p=406#comment-5933</guid>
		<description>trash -l file per the usage seems like it should delete file and list, but it only &quot;lists&quot;

trash -u file per the usage seems like it should delete file and check for update, but it only updates.

You&#039;d maybe think that &quot;trash -l&quot; would give you a size of the entire data in trash, but it does not.  That is, it does not account in the size calculation that data sitting with folders in the trash.

Great little command.  Keep up the good work.</description>
		<content:encoded><![CDATA[<p><span class='eg-image' style='float:left; margin-right:10px; display:block; width:40px' ><img alt='' src='http://0.gravatar.com/avatar/2c0e18b23d40d7f9472a203d76f0cc70?s=40&amp;d=http%3A%2F%2Fhasseg.org%2Fblank-avatar.png%3Fs%3D40&amp;r=G' class='avatar avatar-40 photo' height='40' width='40' /></span>trash -l file per the usage seems like it should delete file and list, but it only &#8220;lists&#8221;</p>
<p>trash -u file per the usage seems like it should delete file and check for update, but it only updates.</p>
<p>You&#8217;d maybe think that &#8220;trash -l&#8221; would give you a size of the entire data in trash, but it does not.  That is, it does not account in the size calculation that data sitting with folders in the trash.</p>
<p>Great little command.  Keep up the good work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: trash your file by command-line on macos at sa note &#8211; such another note site</title>
		<link>http://hasseg.org/blog/post/406/trash-files-from-the-os-x-command-line/comment-page-1/#comment-5672</link>
		<dc:creator>trash your file by command-line on macos at sa note &#8211; such another note site</dc:creator>
		<pubDate>Mon, 25 Oct 2010 08:58:09 +0000</pubDate>
		<guid isPermaLink="false">http://hasseg.org/blog/?p=406#comment-5672</guid>
		<description>[...] ???????????????????????, ????????? ?????????????????????????????????????????????????????????????trash???????? ???http://hasseg.org/blog/post/406/trash-files-from-the-os-x-command-line/ [...]</description>
		<content:encoded><![CDATA[<p>[...] ???????????????????????, ????????? ?????????????????????????????????????????????????????????????trash???????? ???<a href="http://hasseg.org/blog/post/406/trash-files-from-the-os-x-command-line/" rel="nofollow">http://hasseg.org/blog/post/406/trash-files-from-the-os-x-command-line/</a> [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: has</title>
		<link>http://hasseg.org/blog/post/406/trash-files-from-the-os-x-command-line/comment-page-1/#comment-2152</link>
		<dc:creator>has</dc:creator>
		<pubDate>Wed, 10 Mar 2010 20:15:58 +0000</pubDate>
		<guid isPermaLink="false">http://hasseg.org/blog/?p=406#comment-2152</guid>
		<description>Bug filed on ASTranslate. It does that sometimes. Try [[finder delete: nsArrayOfNSURLs] send]. 

&lt;blockquote&gt; executeAppleEvent:error: to send Apple events to other apps &lt;/blockquote&gt;

Correct, -executeAppleEvent:error: is for invoking handlers in a loaded AppleScript, which is only worth the effort if it&#039;s a user-supplied script (i.e. you&#039;re making your application attachable). Using ASSendMessage to dispatch a core/delo event directly to Finder is the easiest way to go here. One of these days I&#039;ll need to look into building appscript as a static library; frameworks are pretty hopeless when it comes to developing CLI tools.</description>
		<content:encoded><![CDATA[<p><span class='eg-image' style='float:left; margin-right:10px; display:block; width:40px' ><a rel='external nofollow' href='http://appscript.sourceforge.net'><img alt='' src='http://0.gravatar.com/avatar/6bdc6b64f46bbb6dd6e84b5ba68385fc?s=40&amp;d=http%3A%2F%2Fhasseg.org%2Fblank-avatar.png%3Fs%3D40&amp;r=G' class='avatar avatar-40 photo' height='40' width='40' /></a></span>Bug filed on ASTranslate. It does that sometimes. Try [[finder delete: nsArrayOfNSURLs] send]. </p>
<blockquote><p> executeAppleEvent:error: to send Apple events to other apps </p></blockquote>
<p>Correct, -executeAppleEvent:error: is for invoking handlers in a loaded AppleScript, which is only worth the effort if it&#8217;s a user-supplied script (i.e. you&#8217;re making your application attachable). Using ASSendMessage to dispatch a core/delo event directly to Finder is the easiest way to go here. One of these days I&#8217;ll need to look into building appscript as a static library; frameworks are pretty hopeless when it comes to developing CLI tools.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ali Rantakari</title>
		<link>http://hasseg.org/blog/post/406/trash-files-from-the-os-x-command-line/comment-page-1/#comment-2148</link>
		<dc:creator>Ali Rantakari</dc:creator>
		<pubDate>Wed, 10 Mar 2010 02:40:49 +0000</pubDate>
		<guid isPermaLink="false">http://hasseg.org/blog/?p=406#comment-2148</guid>
		<description>Hi has, and thanks for your helpful suggestions!

This can definitely be accomplished just with AppleScript as well, although you&#039;d need a bit more than the script you provided (it doesn&#039;t resolve paths relative to the current working directory and it authenticates the user once for each file the user lacks access rights for).

Good that you mentioned the sanitization because I did indeed forget to escape double quotes in file paths :). I applied a quick fix for that but I also started to look into constructing the NSAppleEventDescriptor manually and sending it as an Apple Event to Finder, which I thought would be the best way to go around the problems that the dynamic code generation brings. Apparently you can&#039;t use executeAppleEvent:error: to send Apple events to other apps but I found some examples of how to get it done with AESendMessage(). Version 0.7.0 now has this fix.

I looked at appscript as well (I&#039;ve had it in my bookmarks for a long time but I&#039;ve forgotten about it), and tried to translate this with ASTranslate:

[cc lang=&quot;applescript&quot;]
tell application &quot;Finder&quot; to delete every item of {(POSIX file &quot;/path/one&quot;), (POSIX file &quot;/path/two&quot;)}
[/cc]

The Ruby and Python examples ASTranslate gave me seemed fine, but the Objective-C translation didn&#039;t:

[cc lang=&quot;objc&quot;]
#import &quot;FNGlue/FNGlue.h&quot;
FNApplication *finder = [FNApplication applicationWithName: @&quot;Finder&quot;];
id result = [[finder delete] send];
[/cc]

Apparently, though, you can just create an NSArray of NSURLs and pass it as an argument to FNApplication&#039;s -delete:. For this app, though, I decided to leave appscript out because it seemed a bit overkill to add a whole library&#039;s worth of dependencies just to strip ~20 lines of code down to ~2 (some might disagree, but this is what I decided). Anyway, your comments were very helpful.</description>
		<content:encoded><![CDATA[<p><span class='eg-image' style='float:left; margin-right:10px; display:block; width:40px' ><a rel='external nofollow' href='http://hasseg.org'><img alt='' src='http://1.gravatar.com/avatar/d15666558763fe2deffd703eeff36761?s=40&amp;d=http%3A%2F%2Fhasseg.org%2Fblank-avatar.png%3Fs%3D40&amp;r=G' class='avatar avatar-40 photo' height='40' width='40' /></a></span>Hi has, and thanks for your helpful suggestions!</p>
<p>This can definitely be accomplished just with AppleScript as well, although you&#8217;d need a bit more than the script you provided (it doesn&#8217;t resolve paths relative to the current working directory and it authenticates the user once for each file the user lacks access rights for).</p>
<p>Good that you mentioned the sanitization because I did indeed forget to escape double quotes in file paths :). I applied a quick fix for that but I also started to look into constructing the NSAppleEventDescriptor manually and sending it as an Apple Event to Finder, which I thought would be the best way to go around the problems that the dynamic code generation brings. Apparently you can&#8217;t use executeAppleEvent:error: to send Apple events to other apps but I found some examples of how to get it done with AESendMessage(). Version 0.7.0 now has this fix.</p>
<p>I looked at appscript as well (I&#8217;ve had it in my bookmarks for a long time but I&#8217;ve forgotten about it), and tried to translate this with ASTranslate:</p>
<div class="codecolorer-container applescript mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="applescript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff0033; font-weight: bold;">tell</span> <span style="color: #0066ff;">application</span> <span style="color: #009900;">&quot;Finder&quot;</span> <span style="color: #ff0033; font-weight: bold;">to</span> <span style="color: #0066ff;">delete</span> <span style="color: #ff0033;">every</span> <span style="color: #0066ff;">item</span> <span style="color: #ff0033; font-weight: bold;">of</span> <span style="color: #000000;">&#123;</span><span style="color: #000000;">&#40;</span><span style="color: #0066ff;">POSIX file</span> <span style="color: #009900;">&quot;/path/one&quot;</span><span style="color: #000000;">&#41;</span>, <span style="color: #000000;">&#40;</span><span style="color: #0066ff;">POSIX file</span> <span style="color: #009900;">&quot;/path/two&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span></div></div>
<p>The Ruby and Python examples ASTranslate gave me seemed fine, but the Objective-C translation didn&#8217;t:</p>
<div class="codecolorer-container objc mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6e371a;">#import &quot;FNGlue/FNGlue.h&quot;</span><br />
FNApplication <span style="color: #002200;">*</span>finder <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>FNApplication applicationWithName<span style="color: #002200;">:</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Finder&quot;</span><span style="color: #002200;">&#93;</span>;<br />
<span style="color: #a61390;">id</span> result <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>finder delete<span style="color: #002200;">&#93;</span> send<span style="color: #002200;">&#93;</span>;</div></div>
<p>Apparently, though, you can just create an NSArray of NSURLs and pass it as an argument to FNApplication&#8217;s -delete:. For this app, though, I decided to leave appscript out because it seemed a bit overkill to add a whole library&#8217;s worth of dependencies just to strip ~20 lines of code down to ~2 (some might disagree, but this is what I decided). Anyway, your comments were very helpful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: has</title>
		<link>http://hasseg.org/blog/post/406/trash-files-from-the-os-x-command-line/comment-page-1/#comment-2145</link>
		<dc:creator>has</dc:creator>
		<pubDate>Tue, 09 Mar 2010 19:36:34 +0000</pubDate>
		<guid isPermaLink="false">http://hasseg.org/blog/?p=406#comment-2145</guid>
		<description>You can do this in AppleScript; just save the following as plain text and make it executable:

&lt;code&gt;#!/usr/bin/osascript

on run file_paths
	repeat with path_ref in file_paths
		set f to POSIX file path_ref
		tell application &quot;Finder&quot; to delete f
	end repeat
	return
end run&lt;/code&gt;

Re. the code generation approach, remember to sanitize your inputs if you don&#039;t want nasty surprises. Or, pack your args into an NSAppleEventDescriptor and pass to -executeAppleEvent:error: (though in this case it&#039;d be as easy just to build a core/delo event and send it directly to Finder). Or, if you&#039;re using &lt;a href=&quot;http://appscript.sourceforge.net&quot; rel=&quot;nofollow&quot;&gt;appscript&lt;/a&gt; (which is more capable than SB), run the AppleScript command through ASTranslate to get its Python/Ruby/ObjC equivalent.</description>
		<content:encoded><![CDATA[<p><span class='eg-image' style='float:left; margin-right:10px; display:block; width:40px' ><a rel='external nofollow' href='http://appscript.sourceforge.net'><img alt='' src='http://0.gravatar.com/avatar/6bdc6b64f46bbb6dd6e84b5ba68385fc?s=40&amp;d=http%3A%2F%2Fhasseg.org%2Fblank-avatar.png%3Fs%3D40&amp;r=G' class='avatar avatar-40 photo' height='40' width='40' /></a></span>You can do this in AppleScript; just save the following as plain text and make it executable:</p>
<div class="codecolorer-container text mac-classic codecolorer-customstyle" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">#!/usr/bin/osascript<br />
<br />
on run file_paths<br />
&nbsp; &nbsp; repeat with path_ref in file_paths<br />
&nbsp; &nbsp; &nbsp; &nbsp; set f to POSIX file path_ref<br />
&nbsp; &nbsp; &nbsp; &nbsp; tell application &quot;Finder&quot; to delete f<br />
&nbsp; &nbsp; end repeat<br />
&nbsp; &nbsp; return<br />
end run</div></div>
<p>Re. the code generation approach, remember to sanitize your inputs if you don&#8217;t want nasty surprises. Or, pack your args into an NSAppleEventDescriptor and pass to -executeAppleEvent:error: (though in this case it&#8217;d be as easy just to build a core/delo event and send it directly to Finder). Or, if you&#8217;re using <a href="http://appscript.sourceforge.net" rel="nofollow">appscript</a> (which is more capable than SB), run the AppleScript command through ASTranslate to get its Python/Ruby/ObjC equivalent.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

