Created
March 1, 2013 19:25
-
-
Save waffle2k/5067080 to your computer and use it in GitHub Desktop.
When exporting templates from zabbix, it defaults the download name to something generic. It's useful to then rename all of the xml files to reflect their template name.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -s | |
use XML::Simple; | |
my @files = grep { /\.xml$/ and -f $_ } @ARGV; | |
for my $filename ( @files ){ | |
my $xml = XML::Simple->new; | |
my $data = $xml->XMLin( $filename ); | |
next unless defined $data->{templates}->{template}->{name}; | |
if( $data->{templates}->{template}->{name} eq $data->{templates}->{template}->{template} ){ | |
print "I: rename [$filename] to [$data->{templates}->{template}->{name}.xml]\n" | |
unless $filename eq "$data->{templates}->{template}->{name}.xml"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment