56 lines
1.1 KiB
Python
56 lines
1.1 KiB
Python
#!/usr/bin/env python
|
|
|
|
# simple script to organize the vxheaven collection
|
|
#
|
|
# Usage:
|
|
# Create input list with "ls > ../list" ran inside where you extracted the vxheaven archive
|
|
# Run this script
|
|
# ... Watch it go?
|
|
|
|
|
|
import os
|
|
import sys
|
|
|
|
from pathlib import Path, PurePath
|
|
|
|
class VxFolderInfo:
|
|
def __init__(self, vtype, platform, family, filename):
|
|
self.vtype = vtype
|
|
self.platform = platform
|
|
self.family = family
|
|
self.filename = filename
|
|
|
|
def MakePath(self):
|
|
return Path(os.getcwd()) / self.vtype / self.platform / self.family
|
|
|
|
|
|
def main():
|
|
folderInfo = []
|
|
listfile = open('../list', 'r')
|
|
|
|
for line in listfile:
|
|
line = line.strip()
|
|
split = line.split(".")
|
|
|
|
try:
|
|
folderInfo.append(VxFolderInfo(split[0], split[1], split[2], line))
|
|
except:
|
|
print(f'invalid format for {split}/{line}')
|
|
|
|
listfile.close()
|
|
|
|
for item in folderInfo:
|
|
srcPath = Path(item.filename)
|
|
dstPath = item.MakePath()
|
|
|
|
if not dstPath.is_dir():
|
|
print(f'making directory tree {str(dstPath)}')
|
|
dstPath.mkdir(parents=True)
|
|
|
|
if srcPath.is_file():
|
|
newDst = dstPath / item.filename
|
|
print(f'moving {str(srcPath)} to {str(newDst)}')
|
|
srcPath.rename(newDst)
|
|
|
|
main()
|