groups

name language licence
Rename a lot of files in a directory 1 Perl Other
Color on Mac terminal Shell Other
Commenting code including comments C++ Other
Convert UInt_t to binary C++ Other
Convert string to integer C++ Other
Description Latex Other
Reading a TRefArray C++ Other
SetDirectory C++ Other

< 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 >



language: Perl
licence: Other

Rename a lot of files in a directory 1

options: view full snippetsend to code collector
#!/usr/bin/perl -w

opendir(DIR, ".");
@files = grep(/\.root$/,readdir(DIR));
closedir(DIR);

foreach $file (@files) {
  if ( length($file) == 13 ) {
    $file1 = $file;
    substr($file, 2, 1) = '_';
    system("mv $file1 $file\n");
  }
}

	
(Continues...)