Debian Codegraph @

tools/imglab/convert_imglab_paths_to_relative

raw
1 #!/usr/bin/perl
2
3 use File::Spec;
4
5 die "This script converts all the file names in an imglab XML file to have paths relative to the current folder. Call it like this: ./convert_imglab_paths_to_relative some_file.xml" if @ARGV != 1;
6
7 $file = @ARGV[0];
8 open(INFO, $file) or die('Could not open file.');
9
10 foreach $line (<INFO>)
11 {
12 if (index($line, 'file=\'') != -1)
13 {
14 $line =~ /file='(.*)'/;
15 $relpath = File::Spec->abs2rel($1);
16 $line =~ s/$1/$relpath/;
17 print $line
18 }
19 else
20 {
21 print $line
22 }
23 }
24