Rename a file after the name of its parent dir

Started a thread in beginners but I thought someone from this forum may have an idea as well. Thanks!

EDITED BY REBORG

Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.

To rename a file to have the same names as parent directory you could do the following:

cd /home/test
inputfile="tempfile"
dirname=`pwd`
filename=basename $dirname
mv $inputfile $filename

Now you should see a file called test in /home/test.

Thank you very much for the help.