Hi Experts,
I am trying to write a shell script for converting upper case names of .cpp & .h files into lower case,
my script is checking if the file is not directory, if it was directory it will print a warning,
then it will check if the file name is not in lower case already, if it is, then it prints a warning message
and it checks also if there exists a file with same lower case name, if there was it will print a warning again,
at the end it will convert the name of the file into lower case.
could any one tell me that if this script is good enough and working , and also I thought in some places I need to quite the program but I dont know how to quite in Unix...
foreach file (*.cpp *.h) // loop for .cpp & .h file
if (-d $file )then // if the file is directory
echo 'Warning: $file is Directory' // print warning message
elseif (-f $file) then // else if it is file
set var=$file // set file to variable
// convert name of variable into lowercase and then give its value to newvar
set varnew=`echo var | sed 'y/ABCDEFGHIJKLMNOPQRSTUVW
XYZ/abcdef
ghijklmnop
qrstuvwxyz
/'`
if ($var==$varnew) then // compare the name when converted to lower case and the name at the beggining
echo '$file: file name aready in lower case!' // if same prints warning
// quite from the program
endif // end if
if (-e $varnew) then // check if any file with same name in lowercase exists
echo '$file = with lower case in exist, cant convert to lower case' // print warning
//quite
endif
mv $file $varnew // move value of varnew to file (change its name??)
endif
end
Start Free Trial