Urban Terror Forums: script for demos - Urban Terror Forums

Jump to content

 Login | Register 
Advertisement
  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • This topic is locked

script for demos Rate Topic: -----

#1 User is offline   mitsubishi Icon

  • Account: mitsubishi
  • Country:
  • Joined: 28-February 10
  • Posts: 13,481

Posted 21 February 2005 - 11:08 PM

I've made this small script to rename q3 demos recorded with the /recorddemo command to be able to run them from the easy to use in-game menu. The demo names generated by that command are very explanatory but if they are in the wrong case are pain to rename because they are long, and a pain to be typed for the /demo command.

I'm a perl n00b so please improve it if you can and I'll update this message. Thanks.

uhm, the first thing I would improve if I took the time for it, is to make it more "forgiving" to unrelated file/dirnames if run for totally unrelated files, so be carefull with it as it is now and do not run it as "./script /*". :-)

instructions:
1. paste it to an empty file
2. It would run with "perl file" (or "./file" if "chmod +x file" is run)
3. cd to ~/.q3a/q3ut3/demos
4. It is NOT forgiving so it doesn't do anything by itself, a "glob" should be given, e.g. "./script *68" or "./script 2005_20_1_7_21_2_FS_UT_ABBEY2_TDM.dm_68"
5. Since it is not forgiving it will rename unrelated files/dirs to weird names like "dm_68" if used with a "*", so be carefull.

#!/usr/bin/perl -w

use strict;

for (@ARGV) {
  print "renaming $_n";
    m/(.*.)(.*)/;
    my $new1 = uc($1);
    my $new_name = $new1."dm_68";
  print "  to $new_namen";
    rename $_, $new_name;
}


example:
$ ./script 2005_16_0_9_22_*
renaming 2005_16_0_9_22_19_fs_jumpit_FFA.dm_68
to 2005_16_0_9_22_19_FS_JUMPIT_FFA.dm_68
renaming 2005_16_0_9_22_40_fs_jumpit_FFA.dm_68
to 2005_16_0_9_22_40_FS_JUMPIT_FFA.dm_68
$

#2 User is offline   HoboHumpinSlut (old) Icon

  • Joined: 07-February 04
  • Posts: 2,308

Posted 22 February 2005 - 01:02 AM

for i in `ls *.dm_68` ; do mv $i `echo $i | awk -F . '{ print $1 }' | tr a-z A-Z`.dm_68 ; done ;


#3 User is offline   Trolan (old) Icon

  • Joined: 27-June 04
  • Posts: 190
  • LocationMilpitas, CA

Posted 22 February 2005 - 01:31 AM

Leave it to Hobo to make something a little tigher. Only one little, teensy problem with it: if the demo filename has more than the one period in it. :) Feexed version below. Probably won't work with an ancient BSD version of awk, of which I don't think anything distro'd in the past 5 years will even have... except maybe Solaris. They tend to ship with the minimalist versions of the shell utils.

#!/bin/sh

for i in `ls *.dm_68`
do
   mv $i `echo $i | awk '{ print substr($1, 0, length($1) - length(".dm_68")) }' | tr a-z A-Z`.dm_68
done


#4 User is offline   mitsubishi Icon

  • Account: mitsubishi
  • Country:
  • Joined: 28-February 10
  • Posts: 13,481

Posted 22 February 2005 - 02:00 AM

you've ruined my perl code :cry:

I'm going to use "psh - the perl shell" now to show you :wink:

j/k

BTW, that's slightly unrelated but I was wondering about it for a while. How can we make a pipe out of files that quake3 creates?

At first I was thinking about it for screenshots to feed them directly to mencoder.It could also be used I guess to rename those demo files.

#5 User is offline   HoboHumpinSlut (old) Icon

  • Joined: 07-February 04
  • Posts: 2,308

Posted 22 February 2005 - 07:36 AM

hehe...sorry, just had to do it ;)
i never saw a demo with a 2nd dot, at least q3 doesnt usually create such...well, maybe when speccing |it|autoaim.cfg...

fs: guess that's hard to do, as mencoder needs the number of images when started i think.

bullet_loaderAdvertisement

#6 User is offline   illogical Icon

  •   verified user   
    Retired Master Server Administrator
  • Account: illogical
  • Main tag: 6th|
  • Country:
  • Joined: 08-March 10
  • Posts: 2,349

Posted 22 February 2005 - 07:43 AM

Quake 3 may not generate a demo with a second period, but you should handle it regardless ;-) Be open for you take in, be strict on what you put out.

#7 User is offline   HoboHumpinSlut (old) Icon

  • Joined: 07-February 04
  • Posts: 2,308

Posted 22 February 2005 - 06:13 PM

agreed.

#8 User is offline   CorlacolII (old) Icon

  • Joined: 03-June 04
  • Posts: 44

Posted 30 March 2005 - 05:02 PM

Noobz :twisted:

portable version:


#!/bin/sh
e=.dm_68
for i in *$e; do
    mv $i $(echo ${i%$e}| tr a-z A-Z)$e
done



Or with zsh:
#!/usr/bin/env zsh
e=.dm_68
for i in *$e; do
mv $i ${${i%$e}:u}$e
done

#9 User is offline   Trolan (old) Icon

  • Joined: 27-June 04
  • Posts: 190
  • LocationMilpitas, CA

Posted 31 March 2005 - 01:22 PM

Wow, people actually use the variable flags? ;) I never got too into fiddling with them as it seems every flavor of shell has their own syntax, whereas most of the rest of the code syntax tends to be fairly standardized. Does make it a bit more concise.

#10 User is offline   MrSentry Icon

  • Account: mrsentry
  • Main tag: 6th|
  • Country:
  • Joined: 28-February 10
  • Posts: 940

Posted 01 April 2005 - 02:59 PM

OMG Geeky Nerds!!!!!!!!!!!!!!!!!!

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users

Advertisement


Copyright © 1999-2024 Frozensand Games Limited  |  All rights reserved  |  Urban Terror™ and FrozenSand™ are trademarks of Frozensand Games Limited

Frozensand Games is a Limited company registered in England and Wales. Company Reg No: 10343942