Results 1 to 4 of 4
Hi friends!
I've fixed an tarball damaged and now obtain many file with the same name into;
I tried to create a script based on a previous originally based on ...
- 09-17-2010 #1Just Joined!
- Join Date
- Sep 2010
- Posts
- 2
script extract tar file containg file same name
Hi friends!
I've fixed an tarball damaged and now obtain many file with the same name into;
I tried to create a script based on a previous originally based on the "zipfile" module:
original:
modified:Code:#!/usr/bin/env python import os import sys import tarfile count = 0 t = tarfile.TarFile(sys.argv[1],"r") for info in t.infolist(): directory = str(count) os.makedirs(directory) t.extract(info,directory) count += 1 t.close()
Code:#!/usr/bin/env python import os import sys import tarfile count = 0 t = tarfile.TarFile(sys.argv[1],"r") for info in t.infolist(): directory = str(count) os.makedirs(directory) t.extract(info,directory) count += 1 t.close()
but obtain error becouse the tarfile has not the attribute "infolist"
how i could change correctly the script for the tarfile module?
many many thanks!
- 09-20-2010 #2
The first and the second code sample are basically the same, except some whitespaces? Have you mis-posted something?
- 09-20-2010 #3Just Joined!
- Join Date
- Sep 2010
- Posts
- 2
Hoops! Sorry, this is the unmodified script:
Code:#!/usr/bin/env python import os import sys import zipfile count = 0 z = zipfile.ZipFile(sys.argv[1],"r") for info in z.infolist(): directory = str(count) os.makedirs(directory) z.extract(info,directory) count += 1 z.close()
- 09-20-2010 #4
well, tar and zip files are handled differently in python. what I mean is, that the python api simply differs. you'll have to adapt the script a bit more than that.


Reply With Quote