Root classes instead bat/bash/phyton scripts

Hi, ROOTers!

It is interesting to know is it possible to perform directory/file system operations (create, delete, rename, move) using root staff? For example I have such tasks:

  1. get current directory path;
  2. find in current directory all files with extension “.txt”, rename them using extension “.dat”, also replace symbol “-” by “_” in basenames;
  3. find in current directory all files with extension “.doc”, move them to another arbitrary directory;
  4. find in current directory all files with extension “.ppt” and delete them;
  5. call inside the root script some external execute program which must work with “.dat” files.

Please be so kind list the appropriate root script in order to perform these tasks.


TSystem::gSystem (e.g. TUnixSystem)
TString and/or
many of the “standard” C / C++ functions and classes

Thanks for these references, but I need an example of working script.


Had to think by myself:

int script()

	const int process=1, nFiles=10;
	char *name, *card, *path;
	switch (process)
		case 1: 
		case 2: 
	//////////// file loop //////////////////
	for (unsigned i=1; i<=nFiles; ++i)
			gSystem->Exec(Form("rapgap32 < %s > %s%03d.zdi",card,name,i));	
			gSystem->Exec("./run_diskread_new > /dev/null");			
			gSystem->Exec("rm example.zmc");			
			gSystem->Exec(Form("mv EXAMPLE.fz %s%03d",name,i));
			gSystem->Exec(Form("gzip %s%03d",name,i));
			gSystem->Exec(Form("mv %s%03d.gz %s",name,i,path));
			gSystem->Exec(Form("mv %s%03d.zdi %s",name,i,path));
	return 0;

Good ! you found the solution. =D>
Note also that you may do more in a shell script instead of calling several time gSystem->Exec…
You can group your shell commands in “your_script” and do only:

gSystem->Exec(Form(your_script %s",name,i,path));