<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Scarabée Software: Forum — Rename dir with number of files?]]></title>
		<link>https://scarabee-software.net/forum/viewtopic.php?id=487</link>
		<atom:link href="https://scarabee-software.net/forum/extern.php?action=feed&amp;tid=487&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Rename dir with number of files?.]]></description>
		<lastBuildDate>Thu, 12 Nov 2015 15:54:53 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Rename dir with number of files?]]></title>
			<link>https://scarabee-software.net/forum/viewtopic.php?pid=1289#p1289</link>
			<description><![CDATA[<p>Thank you all for the suggestions.<br />Remi, I&#039;ve never tried the Tools option. When I get a chance I will give it a try.</p><p>So, perhaps you could add additional variable input &amp; negative index numbers to your list of possible enhacements to %T.<br />Consider, too, returning multiple lines from the text file (ie 2-4, 0=all) for post-processing with regex (assuming the regex engine works on multi-line text strings, which I haven&#039;t tested)</p><p>Thanks again for the help.<br />I&#039;m particularly pleased, now have an easy way to rename path from file names.</p>]]></description>
			<author><![CDATA[null@example.com (daffdaemon)]]></author>
			<pubDate>Thu, 12 Nov 2015 15:54:53 +0000</pubDate>
			<guid>https://scarabee-software.net/forum/viewtopic.php?pid=1289#p1289</guid>
		</item>
		<item>
			<title><![CDATA[Re: Rename dir with number of files?]]></title>
			<link>https://scarabee-software.net/forum/viewtopic.php?pid=1287#p1287</link>
			<description><![CDATA[<p>Hello,</p><p>I noticed you seemed to start your DOS commands manually via a extern &quot;cmd&quot; command.<br />Have you tried using the Siren&#039;s &quot;Tools&quot; feature ?<br />I have made some tests and it seems to work correctly.<br />For example to create the &quot;numfiles.txt&quot; files I added a new entry in &quot;Tools&quot; :<br />Name : Create numfiles.txt<br />Command : cmd /C \&quot;dir /b /a-d \&quot;%f\&quot; | find&nbsp; /c /v \&quot;\&quot; &gt; \&quot;%f\\numfiles.txt\&quot;\&quot;</p><p>Just a reminder : the &quot;tools&quot; are executed on highlighted files, not the selected ones.</p><p>Regards</p>]]></description>
			<author><![CDATA[null@example.com (Rémi)]]></author>
			<pubDate>Thu, 12 Nov 2015 09:48:44 +0000</pubDate>
			<guid>https://scarabee-software.net/forum/viewtopic.php?pid=1287#p1287</guid>
		</item>
		<item>
			<title><![CDATA[Re: Rename dir with number of files?]]></title>
			<link>https://scarabee-software.net/forum/viewtopic.php?pid=1285#p1285</link>
			<description><![CDATA[<p>Yes, negative numbers are not implemented for %T variable.</p><p>But you could had used SORT <br />for /D %i in (*) do @(<strong>sort </strong>/R &quot;%i\dirfiles.txt&quot; <strong>/O </strong>&quot;%i\dirfiles.txt&quot;)</p><br /><p>But <strong>DIR </strong>has also a<strong> reverse switch</strong> for the /O operator: -</p><br /><br /><p>I had two additional ideas:<br />1. prefix the temp file name&nbsp; with zzz or 000 (zero) respective to sort them out <br />of the way, to be NOT the first / last file in folder.<br />2. add a (s///) modifier to the %T variable to remove that temp file name, if it is the only one in folder.</p><br /><br /><p>So I have testet this:</p><p>To get first file from folder (Note the zzz prefix) :<br />step 1:for /D %i in (*) do @(dir /b /a-d <strong>/on</strong> &quot;%i&quot; &gt; &quot;%i\<strong>zzz</strong>dirfiles.txt&quot;)<br />step 2: %T{%fa(s/$/\\zzzdirfiles.txt/),1}<strong>(s/zzzdirfiles.txt//</strong>);%b</p><br /><p>To get last file from folder (Note the /o-n DIR switch and the 000 prefix):<br />step 1:for /D %i in (*) do @(dir /b /a-d <strong>/o-n</strong> &quot;%i&quot; &gt; &quot;%i\<strong>000</strong>dirfiles.txt&quot;)<br />step 2: %T{%fa(s/$/\\000dirfiles.txt/),1}<strong>(s/000dirfiles.txt//)</strong>;%b</p><br /><br /><p>Of course we would use &#039;000&#039; and &#039;zzz&#039; without extension as temp file name only, to make typing easier&nbsp; <img src="https://scarabee-software.net/forum/img/smilies/cool.png" width="15" height="15" alt="cool" /> </p><br /><p>HTH?&nbsp; <img src="https://scarabee-software.net/forum/img/smilies/big_smile.png" width="15" height="15" alt="big_smile" /></p>]]></description>
			<author><![CDATA[null@example.com (Stefan)]]></author>
			<pubDate>Wed, 11 Nov 2015 18:57:09 +0000</pubDate>
			<guid>https://scarabee-software.net/forum/viewtopic.php?pid=1285#p1285</guid>
		</item>
		<item>
			<title><![CDATA[Re: Rename dir with number of files?]]></title>
			<link>https://scarabee-software.net/forum/viewtopic.php?pid=1284#p1284</link>
			<description><![CDATA[<p>Again cut post</p><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><p>(At least 60 seconds have to pass between posts. Please wait a while and try posting again.)</p>]]></description>
			<author><![CDATA[null@example.com (Stefan)]]></author>
			<pubDate>Wed, 11 Nov 2015 18:55:11 +0000</pubDate>
			<guid>https://scarabee-software.net/forum/viewtopic.php?pid=1284#p1284</guid>
		</item>
		<item>
			<title><![CDATA[Re: Rename dir with number of files?]]></title>
			<link>https://scarabee-software.net/forum/viewtopic.php?pid=1283#p1283</link>
			<description><![CDATA[<p>Yes, negative numbers are not implemented for %T variable.But you could had used SORT for /D %i in (*) do @(sort /R</p>]]></description>
			<author><![CDATA[null@example.com (Stefan)]]></author>
			<pubDate>Wed, 11 Nov 2015 18:52:55 +0000</pubDate>
			<guid>https://scarabee-software.net/forum/viewtopic.php?pid=1283#p1283</guid>
		</item>
		<item>
			<title><![CDATA[Re: Rename dir with number of files?]]></title>
			<link>https://scarabee-software.net/forum/viewtopic.php?pid=1280#p1280</link>
			<description><![CDATA[<p>Remi, if you recall, a few months ago, we were talking about renaming folder based on files in the folder.<br />This same technique we used here would work for that, too.</p><p>Example: I have a bunch of folders with non-descript names but the 1st file in each folder is a cover with a name in the form of &quot;Date - Artist - Album.jpg&quot;</p><p>step 1: for /D %i in (*) do @(dir /b /a-d /on &quot;%i&quot; &gt; &quot;%i\dirfiles.txt&quot;)<br />step 2: %T{%fa(s/$/\\dirfiles.txt/),1};%b<br />step 3: for /D %i in (*) do @(del &quot;%i\dirfiles.txt&quot;)</p><p>Voila!</p><p>One thing I noticed playing around with this. If the file I want to use as folder name is the last file, then the form:<br />%T{%fa(s/$/\\dirfiles.txt/),-1};%b<br />Doesn&#039;t seem to work.</p>]]></description>
			<author><![CDATA[null@example.com (daffdaemon)]]></author>
			<pubDate>Wed, 11 Nov 2015 15:33:30 +0000</pubDate>
			<guid>https://scarabee-software.net/forum/viewtopic.php?pid=1280#p1280</guid>
		</item>
		<item>
			<title><![CDATA[Re: Rename dir with number of files?]]></title>
			<link>https://scarabee-software.net/forum/viewtopic.php?pid=1279#p1279</link>
			<description><![CDATA[<p>Remi, Thanks, Works like a charm.</p><p>step 1, run from cmd prompt, creates numfiles.txt:<br />&nbsp; &nbsp;for /D %i in (*) do @(dir /b /a-d &quot;%i&quot; | find&nbsp; /c /v &quot;&quot; &gt; &quot;%i\numfiles.txt&quot;)</p><p>step 2, run in siren, rename Filename &gt;&gt; Filename (xN) where N = number of files.<br />Note: Have to subtract 1 for numfiles.txt or 2 if thumbs.db exists <br />&nbsp; %b - %T{%fa(s/$/\\numfiles.txt/),1};%b[1,-1] (x%N{1,-1,-1})</p><p>step 3, run from cmd prompt, deletes numfiles.txt<br />&nbsp; for /D %i in (*) do @(del &quot;%i\numfiles.txt&quot;)</p><br /><p>BTW: Sorry about misplacing the post. Yes, please, move the thread to proper place.</p>]]></description>
			<author><![CDATA[null@example.com (daffdaemon)]]></author>
			<pubDate>Wed, 11 Nov 2015 15:15:33 +0000</pubDate>
			<guid>https://scarabee-software.net/forum/viewtopic.php?pid=1279#p1279</guid>
		</item>
		<item>
			<title><![CDATA[Re: Rename dir with number of files?]]></title>
			<link>https://scarabee-software.net/forum/viewtopic.php?pid=1278#p1278</link>
			<description><![CDATA[<p>Rémi wrote:<br />&gt;I have already thought about expanding the expression syntax....<br />&gt;Do not hesitate to give your ideas.</p><br /><p>Just mention that trick to &#039;read files relative to folders&#039; in the help file.<br />Read always first line from each file:<br />%T{  %fa(s/$/\\Text.txt/) , 1 } </p><br /><p>Additional mention the way to &#039;read one file from Sirens&#039; home folder&#039;:<br />%Pe the path to Siren&#039;s executable file&nbsp; <br />Read lines from a single file, but relative to file selection in Siren list view:<br />%T{  %Pe(s/$/\\Text.txt/)     }<br />Of course, if you do not need this portable, relative path, you can also use the absolute path, like e.g.<br />%T{&nbsp; &quot;C:\\Tools\\SirenV3\\Text.txt&quot;&nbsp; &nbsp; &nbsp;}</p><br /><p>- - -<br />BTW: <br />the relative path form works also for me: <br />%T{ %f(s///) ,1} <br />and <br />%T{ %b(s///) ,1}<br />instead of<br />%T{ %fa(s///) ,1}</p>]]></description>
			<author><![CDATA[null@example.com (Stefan)]]></author>
			<pubDate>Tue, 10 Nov 2015 11:18:28 +0000</pubDate>
			<guid>https://scarabee-software.net/forum/viewtopic.php?pid=1278#p1278</guid>
		</item>
		<item>
			<title><![CDATA[Re: Rename dir with number of files?]]></title>
			<link>https://scarabee-software.net/forum/viewtopic.php?pid=1277#p1277</link>
			<description><![CDATA[<p>O.O</p><p>Great solution, Rémi!</p><p>- - -</p><p>%b_(%T{%fa(s/$/\\_SirenNumFiles.txt/),1} files) </p><br /><p>works for me on Siren v3.</p><br /><p>Even with spaces in&nbsp; path.</p><p>- - -</p><p>Examples (some folders without &#039;_SirenNumFiles.txt&#039;):</p><p>Current name&nbsp; &nbsp; New name&nbsp; &nbsp; Sel&nbsp; &nbsp; Type&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />Accents&nbsp; &nbsp; Accents_(6 files)&nbsp; &nbsp; 004 Directory<br />Add-fitting-Zeros&nbsp; &nbsp; Add-fitting-Zeros_( files)&nbsp; &nbsp; 005 Directory<br />AddSerialize inbetween&nbsp; &nbsp; AddSerialize inbetween_(2 files)&nbsp; &nbsp; 006&nbsp; &nbsp; Directory<br />AddSpacebetween Upper case Letter&nbsp; &nbsp; AddSpacebetween Upper case Letter_(1 files)&nbsp; &nbsp; 007&nbsp; &nbsp; Directory&nbsp; &nbsp; <br />AddSpacebetweenLetterAndDigitsOrSymbol&nbsp; &nbsp; AddSpacebetweenLetterAndDigitsOrSymbol_(4 files) 008 Directory<br />b&nbsp; &nbsp; b_( files)&nbsp; &nbsp; 009 Directory</p><br /><p>- - -</p><p>Explanation:</p><p>%b_ &gt;&gt;&gt; origin base name, without extension.</p><p>( &gt;&gt;&gt; A literal &#039;(&#039; sign.</p><p>%T{%fa(s/$/\\_SirenNumFiles.txt/),1} &gt;&gt;&gt;<br />&gt;&gt;&gt; %T{file path,1} expression <br />&gt;&gt;&gt; plus %fa expression as file path<br />&gt;&gt;&gt; with an additional &#039;(s///)&#039;- RegEx search&amp;replace on that %fa expression.</p><p>%fa(s/$/\\_SirenNumFiles.txt/)<br />&gt;&gt;&gt; match the end of the value of %fa <br />&gt;&gt;&gt; and add an (here regex escaped) backslash <br />&gt;&gt;&gt; plus a literal string (here: &#039;_SirenNumFiles.txt&#039;)</p><p> files)&nbsp; &gt;&gt;&gt; literal &#039; files)&#039; sings.</p><br /><p>Fine!</p><p>Thanks Rémi :thumpsup:</p>]]></description>
			<author><![CDATA[null@example.com (Stefan)]]></author>
			<pubDate>Tue, 10 Nov 2015 10:56:38 +0000</pubDate>
			<guid>https://scarabee-software.net/forum/viewtopic.php?pid=1277#p1277</guid>
		</item>
		<item>
			<title><![CDATA[Re: Rename dir with number of files?]]></title>
			<link>https://scarabee-software.net/forum/viewtopic.php?pid=1276#p1276</link>
			<description><![CDATA[<p>Hello,</p><p>There are different ways to get what you want.<br />The simplest seems to be the regular expression modifier.<br />For example : %b_%T{%fa(s/$/\\numfiles.txt/),1}</p><p>Here, the metacharacter &#039;$&#039; (regular expression standard) represents the end the string.<br />In our case the end of &quot;%fa&quot;.<br />&#039;$&#039; is replaced by &quot;\numfiles.txt&quot; which is equivalent to concatenate the two strings.</p><p>I have already thought about expanding the expression syntax to allow a more natural way<br />to achieve this but I haven&#039;t found the right solution yet.<br />Do not hesitate to give your ideas.</p><p>One remark : you posted in the &quot;Siren 1 or 2&quot; part of this forum but this expression<br />won&#039;t work with these old versions.<br />Maybe should I move this post to the &quot;Siren 3&quot; section. Ok ?</p><p>Regards</p>]]></description>
			<author><![CDATA[null@example.com (Rémi)]]></author>
			<pubDate>Tue, 10 Nov 2015 10:11:48 +0000</pubDate>
			<guid>https://scarabee-software.net/forum/viewtopic.php?pid=1276#p1276</guid>
		</item>
		<item>
			<title><![CDATA[Re: Rename dir with number of files?]]></title>
			<link>https://scarabee-software.net/forum/viewtopic.php?pid=1275#p1275</link>
			<description><![CDATA[<p>Stefan, Thanks for suggestion.<br />When I get some time I may download AHK and try out your script.<br />I think there is also a way using DOS rename in a batch file but haven&#039;t quite cracked how to pass variables to the rename command.<br />Sure would be nice if the %T function was enhanced as you suggested!</p>]]></description>
			<author><![CDATA[null@example.com (daffdaemon)]]></author>
			<pubDate>Mon, 09 Nov 2015 20:20:48 +0000</pubDate>
			<guid>https://scarabee-software.net/forum/viewtopic.php?pid=1275#p1275</guid>
		</item>
		<item>
			<title><![CDATA[Re: Rename dir with number of files?]]></title>
			<link>https://scarabee-software.net/forum/viewtopic.php?pid=1274#p1274</link>
			<description><![CDATA[<p>As an workaround, if you really need that feature NOW,<br />see here for basic idea &gt;&gt; <a href="http://scarabee-software.net/forum/viewtopic.php?pid=446#p446">http://scarabee-software.net/forum/view … d=446#p446</a></p><br /><p>And here is such a AHK-script for Siren v3 for your purpose:<br /></p><div class="codebox"><pre><code>#SingleInstance, force
;1) Open Siren v3 and select the wanted folders.
;2) Switch to WinExplorer and execute this script with installed AutoHotkey application
;3) Switch back to Siren and watch what happens....
;================================================
;;;; THE STEPS....
;IF Siren gets the focus:
WinWaitActive, ahk_class wxWindowNR 
;================================================
  ;Enter Siren expression: %fa to get full path of selected folder
  ControlSetText, Edit1,`%fa, Siren
  ;Execute Siren command Ctrl+P
  Send ^p
  ClipWait 
  ;For each copied line (folder name) do:
  Loop parse, clipboard, `n , `r
{
        ;Skip header line:
        if A_Index = 1
            continue

       myLine :=A_LoopField 
       Loop, parse, myLine, %A_Tab%
       {
            ;myLine is tab-delimited.
            ;Get New Name field (2th field):
            if(A_Index = 2){
                vFolder := A_LoopField
                
                ;Read in the file content:
                vFile = %vFolder%\SirenNumfiles.txt
                if (FileExist(vFile)){
                    FileReadLine, vOutputVar,%vFile%, 1
                    myOut = %myOut%%vOutputVar%`r`n
                }
            }
       }
  }
;================================================
;OUTPUT:
;MsgBox OUT:`r`n%myOut%
clipboard := myOut   
WinActivate,  ahk_class wxWindowNR
;Enter Siren expression: &quot;%b_(%C files)&quot; for new name of selected folder:
ControlSetText, Edit1,`%b_(`%C files), Siren
ExitApp
;================================================</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Stefan)]]></author>
			<pubDate>Mon, 09 Nov 2015 16:53:40 +0000</pubDate>
			<guid>https://scarabee-software.net/forum/viewtopic.php?pid=1274#p1274</guid>
		</item>
		<item>
			<title><![CDATA[Re: Rename dir with number of files?]]></title>
			<link>https://scarabee-software.net/forum/viewtopic.php?pid=1272#p1272</link>
			<description><![CDATA[<p>I tried the same trick with %T the other day too without luck ;-)</p><p>Maybe it would be possible for Rémi to enhance %T{} <br />to allow calculating sub-expressions like:      &gt;&gt;&gt; %T{&nbsp; (%pa</p><p>EDIT:<br />was cut...</p><p>&gt;&gt;&gt; %T{&nbsp; (%pa&quot;Numfiles.txt&quot;)&nbsp; } &lt;&lt;&lt;</p>]]></description>
			<author><![CDATA[null@example.com (Stefan)]]></author>
			<pubDate>Mon, 09 Nov 2015 14:42:39 +0000</pubDate>
			<guid>https://scarabee-software.net/forum/viewtopic.php?pid=1272#p1272</guid>
		</item>
		<item>
			<title><![CDATA[Rename dir with number of files?]]></title>
			<link>https://scarabee-software.net/forum/viewtopic.php?pid=1271#p1271</link>
			<description><![CDATA[<p>Goal is to rename a list of directories by appending the number of files contained to the name:<br />&nbsp; &nbsp;REN DirName DirName (xN) ;where N=# of files in the directory</p><p>Siren doesn&#039;t have a file count variable so I thought of using a textfile to save the file count &amp; came up with this to generate the text file from the cmd prompt:<br />for /D %i in (*) do @(dir /b /a-d &quot;%i&quot; | find&nbsp; /c /v &quot;&quot; &gt; &quot;%i\numfiles.txt&quot;)</p><p>So now I have numfiles.txt in each of the directories; I thought I could use %T to rename:</p><p>%b (x%T{&quot;%fa\\numfiles.txt&quot;,1})</p><p>Alas %T appears not to accept variables in the &quot;f&quot; parameter.</p><p>Also thought of continuing at the command prompt but am stumped trying to get REN to accept variable input.</p><p>Ideas? Suggestions?</p>]]></description>
			<author><![CDATA[null@example.com (daffdaemon)]]></author>
			<pubDate>Mon, 09 Nov 2015 00:11:22 +0000</pubDate>
			<guid>https://scarabee-software.net/forum/viewtopic.php?pid=1271#p1271</guid>
		</item>
	</channel>
</rss>
