From 02c2d520c55de7b7274f18f7d6329cb32fa5b4c1 Mon Sep 17 00:00:00 2001 From: modeco80 Date: Sun, 20 Oct 2024 06:33:49 -0400 Subject: [PATCH] init --- vxorg.py | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 vxorg.py diff --git a/vxorg.py b/vxorg.py new file mode 100644 index 0000000..332ca81 --- /dev/null +++ b/vxorg.py @@ -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()