View previous topic :: View next topic |
Author |
Message |
strubbldesign Guru
Joined: 16 Jan 2005 Posts: 354 Location: still somewhere in the matrix but once i was able to look out of it
|
Posted: Mon Mar 25, 2013 5:51 pm Post subject: Easy Phyton Question |
|
|
Hy Everybody!
I got a lot of compressed data strucktured this way...
Quote: | Achriv-Folder
Project1
....Data.00r
....Data.01r
....Data.02r
...
....Data.rar
Project2
....Data.00r
....Data.01r
....Data.02r
...
....Data.rar
Project3
....Data.00r
....Data.01r
....Data.02r
...
....Data.rar
.... |
I managed to extract all the files to the same directory by doing this:
Code: |
for f in Project*/*rar; do unrar e "$f" .; done
|
... well here starts the Questioning...
I have to extract the files to its "Parrent-Directories-Name" i.e. ..../Project3/data4.txt
The other thing is...
I am looking for a Method that copies all theese extracted files to a fifferent location renaming them from i.e. data4.txt to Data4.txt
Code: |
for f in Project*/*.txti; do cp -v "${????? f% ????}.????"; done |
Thanks for you help _________________ Always look on the bright side of live. badu badubadubado |
|
Back to top |
|
|
leo.the_zoo Apprentice
Joined: 04 Jul 2005 Posts: 160 Location: Poland
|
Posted: Mon Mar 25, 2013 7:52 pm Post subject: |
|
|
Why don't you do the following:
Code: | for d in Project*; do cd $d; unrar e Data.rar; cd ..; done |
I guess for a split archive you only need to unrar the base file, right?.
Then renaming data4.txt->Data4.txt would be a bit more complicated:
Code: | for f in Project1; do cp -v $f $(echo -n ${f:0:1} | tr 'a-z' 'A-Z';echo ${f:1:$((${#f}-1))}); done |
Probably someone will propose something simpler
I'd suggest to go for a dry run before you actually rename the files.
Oh... btw where is Python? I only see Bash here |
|
Back to top |
|
|
|