<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/19388" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2013-03-23T16:25:38-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/19388</id>

		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2013-03-23T16:25:38-04:00</updated>

		<published>2013-03-23T16:25:38-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=101290#p101290</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=101290#p101290"/>
		<title type="html"><![CDATA[Need some help please]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=101290#p101290"><![CDATA[
<span style="color:red">Moderator action: Moved to "Script Request"<br><br>/NML_375</span><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sat Mar 23, 2013 4:25 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[COBRa]]></name></author>
		<updated>2013-03-23T15:56:29-04:00</updated>

		<published>2013-03-23T15:56:29-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=101289#p101289</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=101289#p101289"/>
		<title type="html"><![CDATA[Need some help please]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=101289#p101289"><![CDATA[
tbh this way above my skill level i think im gonna need the script coded for me<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12170">COBRa</a> — Sat Mar 23, 2013 3:56 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2013-03-23T11:33:28-04:00</updated>

		<published>2013-03-23T11:33:28-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=101288#p101288</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=101288#p101288"/>
		<title type="html"><![CDATA[Need some help please]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=101288#p101288"><![CDATA[
Maybe, maybe not.<br>It all depends on how you get the names of the directories to be moved.<br>Using glob with a full path qualifier would cause my previous code to fail, as the returned list contains the whole path, not just the filename. The modification to sort that, however, is rather trivial:<div class="codebox"><p>Code: </p><pre><code>set Target "/destination/[string index [file tail $Source] 0]"</code></pre></div>This could be sorted with a regular expression as well, but I'm not sure you'd gain anything by doing it that way...<br><br>For other scenarios, regular expressions might very well be the preferred approach though...<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sat Mar 23, 2013 11:33 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[COBRa]]></name></author>
		<updated>2013-03-23T09:45:08-04:00</updated>

		<published>2013-03-23T09:45:08-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=101287#p101287</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=101287#p101287"/>
		<title type="html"><![CDATA[Need some help please]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=101287#p101287"><![CDATA[
Just a question as the archive has a full alphabetical listing A to Z would it be better to use a regex to select the first letter or something ?<br><br>/site/archive/movies/a,b,c,d etc<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12170">COBRa</a> — Sat Mar 23, 2013 9:45 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2013-03-23T09:27:39-04:00</updated>

		<published>2013-03-23T09:27:39-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=101286#p101286</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=101286#p101286"/>
		<title type="html"><![CDATA[Need some help please]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=101286#p101286"><![CDATA[
Well, in this case, I wrote the examples rather generically. Hence I used /source and /destination as opposed to a real filesystem-path. You'll obviously have to modify these accordingly.<br><br>Also, this is not a complete script, but merely the bits'n'pieces you'll need for the specific task of moving the directories.<br><br>Looking at the updated post, you'd probably have to take some additional steps to avoid moving /site/ARCHIVE/MOVIE to /site/ARCHIVE/MOVIE/M/MOVIE, in case you are using the <strong class="text-strong">glob</strong> + <strong class="text-strong">foreach</strong> method.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sat Mar 23, 2013 9:27 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[COBRa]]></name></author>
		<updated>2013-03-23T09:16:16-04:00</updated>

		<published>2013-03-23T09:16:16-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=101285#p101285</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=101285#p101285"/>
		<title type="html"><![CDATA[Need some help please]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=101285#p101285"><![CDATA[
sorry after posting i realised it wasnt /root it was /site/ARCHIVE will this affect the coding<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12170">COBRa</a> — Sat Mar 23, 2013 9:16 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2013-03-23T08:58:41-04:00</updated>

		<published>2013-03-23T08:58:41-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=101284#p101284</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=101284#p101284"/>
		<title type="html"><![CDATA[Need some help please]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=101284#p101284"><![CDATA[
This would be fully possible, indeed.<br>Most of the things you'll need is available through the "file" and "glob" commands.<br><br>Breaking it down into the various steps:<br><br><strong class="text-strong">Getting a list of directories in the source directory</strong><div class="codebox"><p>Code: </p><pre><code>set Directories [glob -type d /source/*]</code></pre></div>This will retrieve all directories under /root. You might consider filtering out directories with one-letter names if your source and destination trees are the same, otherwize you'd just try to move the /root/T directory to be located under /root/T (being /root/T/T, then /root/T/T/T, etc..).<br>Simplest way to achieve this, is to modify the glob-pattern to something like /source/??*<br><br><strong class="text-strong">Extracting the first letter of the directory to be moved</strong><div class="codebox"><p>Code: </p><pre><code>set Target "/destination/[string index $Source 0]"</code></pre></div>This assumes that the name of the directory to be moved, has been stored in Source.<br>If combining this with the glob-code above, you'd end up with something like this:<div class="codebox"><p>Code: </p><pre><code>foreach Source [glob -type d /source/*] {  set Target "/destination/[string index $Source 0]"  #...}</code></pre></div>If you'd like to make sure that the destination is always upper-case, you could modify the code to use "string toupper":<div class="codebox"><p>Code: </p><pre><code>set Target "/destination/[string toupper [string index $Source 0]]"</code></pre></div><strong class="text-strong">Moving the directory</strong><br>First off, we'll have to make sure that the destination directory already exists. Otherwize, we'd have to create it before doing anything else<div class="codebox"><p>Code: </p><pre><code>if {![file exists $Target]} {  file mkdir $Target} elseif {![file isdirectory $Target]} {  error "$Target already exists as a file"}</code></pre></div>The last part is there to handle the case when there might already be a file with the same name as the target directory.<br><br>Next, do the actual move<div class="codebox"><p>Code: </p><pre><code>file rename -- $Source $Target</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sat Mar 23, 2013 8:58 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[COBRa]]></name></author>
		<updated>2013-03-23T09:14:38-04:00</updated>

		<published>2013-03-23T05:08:10-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=101283#p101283</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=101283#p101283"/>
		<title type="html"><![CDATA[Need some help please]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=101283#p101283"><![CDATA[
Hi not sure if im posting in the right place but im trying to create a script to move folders from a root folder to a alphabetically listed folder<br><br>for example<br><br>This.folder.blah would move from /site/ARCHIVE to /site/ARCHIVE/MOVIE/T     and<br>Same.again.blah would move from /site/ARCHIVE to /site/ARCHIVE/MOVIE/S etc so the script would pick up the the first letter of the first word and move to a predesignated folder<br><br>First of all is this possible if so could someone provide some help to get me started plz as i have no clue on how to make this<br><br>many thx in advance<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12170">COBRa</a> — Sat Mar 23, 2013 5:08 am</p><hr />
]]></content>
	</entry>
	</feed>
