.com.unity Forums

.com.unity Forums (http://forum.shrapnelgames.com/index.php)
-   Space Empires: IV & V (http://forum.shrapnelgames.com/forumdisplay.php?f=20)
-   -   AI Utility (http://forum.shrapnelgames.com/showthread.php?t=11963)

Will April 29th, 2004 04:44 AM

AI Utility
 
At the request of Imperator Fyron, I have created a batch file script that takes all files in a directory, then creates copies of it in all subdirectories, while prefixing the file with the name of the directory and an underscore (_).

Apparently, this would be quite useful to create generic copies of AI files in several subdirectories http://forum.shrapnelgames.com/images/icons/shock.gif http://forum.shrapnelgames.com/image...s/rolleyes.gif http://forum.shrapnelgames.com/images/icons/icon6.gif

linky link

As I don't really have SEIV installed on my computer here, I don't know if this works perfectly. As I remember the AI files, it *should* work. Pretty much, like I said, it just takes the subdirectory (race) name, tacks it on front of the file name with an underscore, and copies the file to the subdirectory. So if you have a set of generic AI template files (sans the race name and underscore) in a directory, you can create one or two or fifty subdirectories, place this script in the directory, double click, and it should automagically do the copying/renaming for you.

I made it on a Windows 2k box, so it should work on 2k, NT, and XP. I have no idea if it will work on 9x. If someone could test it out, that would be grand. If it doesn't work, and someone else doesn't create a 9x Version by the time I get home (mid-May), I'll (hopefully) post a 9x Version then.

Free (as in speech, and as in beer) for everyone. Download, copy, distribute to your heart's content. It's only one line of code, anyway http://forum.shrapnelgames.com/images/icons/icon7.gif It would be appreciated if people did too, I'll probably take it down in a week or so... actually...

... since it *is* just one line of code...

</font><blockquote><font size="1" face="sans-serif, arial, verdana">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">
for /D %%d in (*) do @for %%f in (*.txt) do @copy %%f .\%%d\%%d_%%f
</pre><hr /></blockquote><font size="2" face="sans-serif, arial, verdana">... copy that into a file, give it a .bat extension, and run to your heart's content. I'll leave the link for a while for the more lazy among us. After I take the link down, the code will still be here. Ha!

(Now Fyron, aren't you glad you didn't go about writing a C program to do this? http://forum.shrapnelgames.com/images/icons/icon12.gif http://forum.shrapnelgames.com/images/icons/icon10.gif )

Fyron April 29th, 2004 07:06 AM

Re: AI Utility
 
Yay! Thanks Will! And yes, I am glad I didn't go about writing a c++ program for this. http://forum.shrapnelgames.com/images/icons/tongue.gif

Well... I could not get it to work on this crappy Dell lab computer running XP, probably Home... but that means nothing. http://forum.shrapnelgames.com/images/icons/icon12.gif

What I was thinking was making it only affect .txt files that have "AI_" In their names, and cut off anything before "AI". Would it be too much trouble to alter it to do this?

[ April 29, 2004, 06:12: Message edited by: Imperator Fyron ]

Will April 29th, 2004 11:22 AM

Re: AI Utility
 
Well, I could have the script only grab text files that begin with 'AI_' (AI_*.txt), but the problem is I'm not sure how I could chop off the 'AI_' part and replace it with '%dirname%_'.

I could make a perl script to do this pretty easily, it's just I'm not sure about the extent that Win NT/2k/XP natively support perl. A quick google search hasn't got me much...

I'll take a look into it more tomorrow, but right now I have to sleep, then wake up in the morning, go over a proof of the Completeness and Compactness Theorems of First-Order Languages, then write up a quick enumeration scheme for formulae of a First-Order Language a la the scheme used by Gödel. Something like prime(n) = nth prime number, a<sub>n</sub> (a name in the language) = prime(n), (kth function of i parameters)ƒ<sub>i</sub><sup>k</sup> = prime(1)^k * prime(2)^i, (mth relational symbol between j terms) P<sub>j</sub><sup>m</sup> = prime(3)^m * prime(4)^j, then combining them all together is a huge long product... bleh. What I just typed isn't right, but it's somewhere in the ballpark, I'm too tired...

Will May 1st, 2004 11:32 PM

Re: AI Utility
 
Ok, figured out a sort-of kludge... turns out I don't really need perl, I can work around it in other ways http://forum.shrapnelgames.com/images/icons/icon7.gif

</font><blockquote><font size="1" face="sans-serif, arial, verdana">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">
@for /D %%d in (*) do @for %%f in (AI_*.txt) do @for /F &quot;usebackq tokens=2* delims=_&quot; %%g in ('%%f') do @copy %%f .\%%d\%%d_%%g_%%h
@for /D %%D in (*) do @for %%F in (.\%%D\*.txt_) do @rename .\%%D\%%~nF.txt_ %%~nF.txt
</pre><hr /></blockquote><font size="2" face="sans-serif, arial, verdana">Same procedure as before, takes all files matching AI_*.txt in a directory, and copies it to all subdirectories, taking off the 'AI_' and replacing it with '{subdirname}_'.

Link in first post has been updated.


All times are GMT -4. The time now is 06:03 PM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2025, Shrapnel Games, Inc. - All Rights Reserved.