I need to move all the videos files in a file tree to their parent folders, for example:
origin:
A--sub1--file1
file2
sub2--file3
--file4
sub3--file5
B--sub1--file1
file2
sub2--file3
--file4
sub3--file5
...
what I need:
A--file1
file2
file3
file4
file5
B--file1
file2
file3
file4
file5
...
I am trying to use shell script, and what I am up to is:
for file in `find -name *avi`; do something ; done
I would like to use the file name I get from find -name *avi to get its parent folder's path, which is the part before the second last '/'. But I don't know how to achieve it using shell script, regex may help but I have totally no idea how, any one help?