Adding directory name to filename

Sam Albers tonightsthenight at gmail.com
Fri Mar 5 00:21:28 UTC 2010


Hello all,

I'm looking for a way to rename a bunch of files. I've searched but I
haven't found any references on what I would like to be doing. Maybe there
isn't a way to do what I am thinking.

I would like to rename files by adding the directory name where a particular
file is located to the filename. So in a situation like this, where I have:

/A/B/1.txt
/A/B/2.txt
/A/C/1.txt
/A/C/2.txt


I would like to have all the *.txt files renamed to reflect which directory
they are in like so

/A/B/B1.txt
/A/B/B2.txt
/A/C/B1.txt
/A/C/B2.txt

Have anyone ever done this before? Can anyone recommend a good way to do
this? I have a bunch of files that I need to do this so it would be good to
find an elegant solution.

Thanks in advance.

Sam





-- 
*****************************************************
Sam Albers
Geography Program
University of Northern British Columbia
3333 University Way
Prince George, British Columbia
Canada, V2N 4Z9
phone: 250 960-6777
*****************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20100304/5f16f34e/attachment.html>


More information about the ubuntu-users mailing list