Thanks for the replies.
I apologise if my original question seemed vague, I didn't want to get people side tracked on the LVM rescue.
Quote:
Would I be right in wildly guessing that when you find a full path like ./lost+found/foo_dir/larkstonguesinaspic.avi that you want to rename directory ./lost+found/foo_dir/ as ./lost+find/larkstonguesinaspic/ ?
|
Yes, that is what I am trying to do. However, it is not always the folder that the file is in that needs renaming though, it can sometimes be up the chain, e.g. /lost+found/foo_dir/bar_dir/larkstonguesinaspic.avi, /lost+found/foo_dir/bar_dir/ to be renamed /lost+found/larkstonguesinaspic/bar_dir/
In this respect, the one guarantee I have is that the folder to be renamed will always be in the form of
Quote:
So what if the folder contains more than one file?
|
The folder will probably contain more than one file, but if it contains a media file it will most probably be the name I am looking for. If there is more than one media file then any will do, I just need a better guide than /#12345.
Quote:
How is it that, in general, programmatically, you can determine directory names from the name(s) of the files they contain?
|
Before the great crash of '09 I had a very structured LVM with a hierarchy something like this:
mediashare/tv/someshow/someshow.avi
mediashare/tv/someshow/someshow.nfo
mediashare/tv/someshow/somefile.huh
mediashare/music/sometunes/CD1/sometune.mp3
After the crash, and if I am lucky, it now looks something like this:
lost+found/#123456/someshow.avi
lost+found/#123456/someshow.nfo
lost+found/#123456/somefile.huh
lost+found/#654321/CD1/sometune.mp3
Quote:
...you want to rename the directory to the file name without the extension?
If that is the case, why not copy the file to a new location? Aren't you are going to do that eventually anyway?
|
That's right, but as there is generally more than one file I want to keep the files together. I've already copied the folders to a new location, this is where the bash script will run.
Quote:
If that's the case then something like this (not tested) should do the trick
Code:
dirname="${dirname%/*}$basename
|
Yes, with a bit of refining that is what I am after.
Eddie.