snipt

Ctrl+h for KB shortcuts

AppleScript

Individual Archive

on run {input, parameters}

	repeat with i in input

		try
			tell application "Finder" to set {fName, fContainer} to {(displayed name of i), (POSIX path of ((container of i) as string))}

			do shell script ("zip -r -j " & (quoted form of (fContainer & (fName & ".zip"))) & " " & (quoted form of (POSIX path of (i as string))))
		end try

	end repeat

	return input
end run
https://snipt.net/embed/a25d73180b247681526b3806949eb534/
/raw/a25d73180b247681526b3806949eb534/
a25d73180b247681526b3806949eb534
applescript
AppleScript
14
2019-07-17T08:20:20
True
False
False
/api/public/snipt/46381/
individual-archive
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1"> 1</a> <a href="#L-2"> 2</a> <a href="#L-3"> 3</a> <a href="#L-4"> 4</a> <a href="#L-5"> 5</a> <a href="#L-6"> 6</a> <a href="#L-7"> 7</a> <a href="#L-8"> 8</a> <a href="#L-9"> 9</a> <a href="#L-10">10</a> <a href="#L-11">11</a> <a href="#L-12">12</a> <a href="#L-13">13</a> <a href="#L-14">14</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="k">on</span> <span class="nb">run</span> <span class="p">{</span><span class="nv">input</span><span class="p">,</span> <span class="nv">parameters</span><span class="p">}</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a> <span class="k">repeat</span> <span class="nv">with</span> <span class="nv">i</span> <span class="k">in</span> <span class="nv">input</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a> <span class="k">try</span> </span><span id="L-6"><a name="L-6"></a> <span class="k">tell</span> <span class="nb">application</span> <span class="s2">&quot;Finder&quot;</span> <span class="k">to</span> <span class="k">set</span> <span class="p">{</span><span class="nv">fName</span><span class="p">,</span> <span class="nv">fContainer</span><span class="p">}</span> <span class="k">to</span> <span class="p">{(</span><span class="nv">displayed</span> <span class="na">name</span> <span class="k">of</span> <span class="nv">i</span><span class="p">),</span> <span class="p">(</span><span class="nv">POSIX</span> <span class="na">path</span> <span class="k">of</span> <span class="p">((</span><span class="nv">container</span> <span class="k">of</span> <span class="nv">i</span><span class="p">)</span> <span class="k">as </span><span class="nc">string</span><span class="p">))}</span> </span><span id="L-7"><a name="L-7"></a> </span><span id="L-8"><a name="L-8"></a> <span class="nb">do shell script</span> <span class="p">(</span><span class="s2">&quot;zip -r -j &quot;</span> <span class="o">&amp;</span> <span class="p">(</span><span class="nb">quoted form</span> <span class="k">of</span> <span class="p">(</span><span class="nv">fContainer</span> <span class="o">&amp;</span> <span class="p">(</span><span class="nv">fName</span> <span class="o">&amp;</span> <span class="s2">&quot;.zip&quot;</span><span class="p">)))</span> <span class="o">&amp;</span> <span class="s2">&quot; &quot;</span> <span class="o">&amp;</span> <span class="p">(</span><span class="nb">quoted form</span> <span class="k">of</span> <span class="p">(</span><span class="nv">POSIX</span> <span class="na">path</span> <span class="k">of</span> <span class="p">(</span><span class="nv">i</span> <span class="k">as </span><span class="nc">string</span><span class="p">))))</span> </span><span id="L-9"><a name="L-9"></a> <span class="k">end</span> <span class="k">try</span> </span><span id="L-10"><a name="L-10"></a> </span><span id="L-11"><a name="L-11"></a> <span class="k">end</span> <span class="k">repeat</span> </span><span id="L-12"><a name="L-12"></a> </span><span id="L-13"><a name="L-13"></a> <span class="no">return</span> <span class="nv">input</span> </span><span id="L-14"><a name="L-14"></a><span class="k">end</span> <span class="nb">run</span> </span></pre></div> </td></tr></table>
AppleScript, Archive