Adding directory name to filename

Matt Eskes meskes.mailinglists at gmail.com
Fri Mar 5 07:05:38 UTC 2010


What I would personally do is something like this: say the file is
in /home/user/media/file right? Well I would do it like so...
home.user.media.file since you cannot have a file name in with slashes,
either a slash nor a backslash. This method is currently in use within
Ubuntu be means of the app armor profiles located in /etc/apparmor.d


just my 2 cents.

Matt

-----Original Message-----
From: Sam Albers <tonightsthenight at gmail.com>
Reply-to: "Ubuntu user technical support, not for general discussions"
<ubuntu-users at lists.ubuntu.com>
To: ubuntu-users at lists.ubuntu.com
Subject: Adding directory name to filename
Date: Thu, 4 Mar 2010 16:21:28 -0800

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 --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20100305/08cd182c/attachment.sig>


More information about the ubuntu-users mailing list