This commit is contained in:
Lily Tsuru 2024-10-20 06:33:49 -04:00
commit 02c2d520c5

55
vxorg.py Normal file
View file

@ -0,0 +1,55 @@
#!/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()