I have bunch *.tgz files and when I untar them some how the directory name is different than the name of the tgz file. Example: I have the ab.tgz file and it get change to something like 2012_test_ab, I have feeling this happens because during compression file must have gotten rename of this compress file was within a parent directory etc.
But what I want to do is rename the directory to original name of the file.
I have following one line script to run on terminal, but how can I rename?
for i in *.tgz; do tar xvf $i -C ../stats/; done
How can I modify this to rename the directory thats getting unzip.
Example: When I untar ab.tgz
it gets extracted to directory name is 2013_03_12_18_26_ab
and the files inside that directory but what I want to do is keep the directory name as ab instead of 2013_03_12_18_26_ab
I want ab.tgz
to get extract to ../stats/ab