- Apr 7, 2018
- 228
- 190
I did a simple shit to make my life bit easier after downloading gigs and gigs of assets, it basically finds and extracts all archives, maybe someone will find it handy too.
STEPS:
0. Download and install python (run in cmd "winget install python3", or do it manually).
1. Download and install 7zip.
2. Add the 7z install folder to the system environment variables.
( press win and type ENV, then go to Environment Variables and add your 7z dir to path,
sometimes you will need to run cmd again or restart your system before its added,
you will see that it is added well when you can call 7z from cmd.
3. Check the script and edit what you need, you will most likely need to change the extract path on line 32, keep the same format.
4. Copy the code into a python file with extension .py, name it whatever you like, ie unzip_all.py.
5. Put the unzip_all.py into the folder where you have all your assets zipped,
click on the directory address bar on explorer and type cmd and press enter, or run cmd and go the target dir manually,
and then just type python unzip_all.py or python3 unzip_all.py
If you are using ie DAZ3D, most of your downloaded assets will be two or even three times packed, so after using script once,
you may have to copy the script to the extract folder and run it again, if you need to run it even more times then do it with '-aos' instead of '-aoa' in the command.
STEPS:
0. Download and install python (run in cmd "winget install python3", or do it manually).
1. Download and install 7zip.
2. Add the 7z install folder to the system environment variables.
( press win and type ENV, then go to Environment Variables and add your 7z dir to path,
sometimes you will need to run cmd again or restart your system before its added,
you will see that it is added well when you can call 7z from cmd.
3. Check the script and edit what you need, you will most likely need to change the extract path on line 32, keep the same format.
4. Copy the code into a python file with extension .py, name it whatever you like, ie unzip_all.py.
5. Put the unzip_all.py into the folder where you have all your assets zipped,
click on the directory address bar on explorer and type cmd and press enter, or run cmd and go the target dir manually,
and then just type python unzip_all.py or python3 unzip_all.py
If you are using ie DAZ3D, most of your downloaded assets will be two or even three times packed, so after using script once,
you may have to copy the script to the extract folder and run it again, if you need to run it even more times then do it with '-aos' instead of '-aoa' in the command.
Python:
import sys, os
import subprocess, colorama
print('Working directory :', os.getcwd())
def idx_builder():
#ALL THE FORMATS YOU WANT TO FIND AND EXTRACT:
#----------------------------------------------------------------
extensions = ('rar', 'zip', 'tar', 'gz', '7z')
#----------------------------------------------------------------
all_dirs, all_files = (), ()
for root, ds, files, in os.walk(u".", topdown=False):
path = root.split(os.sep)
for directory in ds:
all_dirs += (directory,)
for file in files:
if file.split('.')[-1] in extensions:
fwp = os.path.join(root, file)[2:]
all_files += (fwp,)
return all_files, all_dirs
if __name__ == '__main__':
all_files, _ = idx_builder()
#----------------------------------------------------------------
#CHANGE THIS - ALL OF THE ASSETS WILL BE EXTRACTED HERE:
target_dest = 'E:\\Downloads\\DAZ_ASSETS\\CONTENT\\TEST\\'
# You should probably use some test directory,
# and check the structures and files afterwards.
# Using some important non-backed-up directory can be risky.
#----------------------------------------------------------------
print(all_files)
print('FILES TO EXTRACT:', len(all_files),'to', target_dest)
errs = 0
for f in all_files:
print('->', f)
#modes : aoa - auto overwrite, aos - auto skip
cmd = ['cmd', '/c', '7z', 'x', f, '-o' + target_dest, '-aoa']
rc = subprocess.run(cmd).returncode
if rc:
print(colorama.Fore.RED + '\n [*] Error ->', colorama.Fore.GREEN+' '.join(cmd))
print(Colorama.Style.RESET_ALL)
os.stat(f)
errs+=1
else: print('OK :', ' '.join(cmd))
print(f'ERRORS : {errs}')
Last edited: