zipremove processes entire folders
This commit is contained in:
parent
6b6c06d0e5
commit
7004c40071
1 changed files with 5 additions and 2 deletions
|
@ -3,6 +3,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
import shutil
|
||||||
|
|
||||||
def filter_and_repack_zip(zip_path):
|
def filter_and_repack_zip(zip_path):
|
||||||
temp_dir = tempfile.TemporaryDirectory()
|
temp_dir = tempfile.TemporaryDirectory()
|
||||||
|
@ -14,7 +15,9 @@ def filter_and_repack_zip(zip_path):
|
||||||
if "(USA" in file or "(USA, Europe)" in file:
|
if "(USA" in file or "(USA, Europe)" in file:
|
||||||
new_zip.writestr(file, original_zip.read(file))
|
new_zip.writestr(file, original_zip.read(file))
|
||||||
|
|
||||||
os.replace(new_zip_path, zip_path)
|
# Remove the original file and move the new file to the original location
|
||||||
|
os.remove(zip_path)
|
||||||
|
shutil.move(new_zip_path, zip_path)
|
||||||
|
|
||||||
def process_directory(directory_path):
|
def process_directory(directory_path):
|
||||||
for zip_file in Path(directory_path).glob('*.zip'):
|
for zip_file in Path(directory_path).glob('*.zip'):
|
||||||
|
|
Loading…
Reference in a new issue