Download OBJECTS-MAPPED/scripts/move_files.py from pebxcvi/PSHomeCacheDepot: direct link, hf CLI and curl.
- Browser
- Download file 1.16 kB
-
https://huggingface.co/datasets/pebxcvi/PSHomeCacheDepot/resolve/main/OBJECTS-MAPPED/scripts/move_files.py
- Command line
-
hf download hf://datasets/pebxcvi/PSHomeCacheDepot/OBJECTS-MAPPED/scripts/move_files.py
-
curl -L -o move_files.py https://huggingface.co/datasets/pebxcvi/PSHomeCacheDepot/resolve/main/OBJECTS-MAPPED/scripts/move_files.py
1.16 kB
| import os | |
| import shutil | |
| def pause_exit(): | |
| input("\nPress Enter to exit...") | |
| source_dir = os.path.dirname(os.path.abspath(__file__)) | |
| hex_digits = "0123456789ABCDEF" | |
| moved_count = 0 | |
| skipped_count = 0 | |
| for filename in os.listdir(source_dir): | |
| source_file = os.path.join(source_dir, filename) | |
| if not os.path.isfile(source_file): | |
| continue | |
| if not filename.lower().endswith(".zip"): | |
| continue | |
| first_digit = filename[0].upper() | |
| if first_digit not in hex_digits: | |
| print(f"Skipping {filename}: first character '{filename[0]}' is not 0-9 or A-F.") | |
| skipped_count += 1 | |
| continue | |
| folder_path = os.path.join(source_dir, first_digit) | |
| dest_file = os.path.join(folder_path, filename) | |
| os.makedirs(folder_path, exist_ok=True) | |
| if os.path.exists(dest_file): | |
| print(f"Skipping {filename}: already exists in {first_digit}\\") | |
| skipped_count += 1 | |
| continue | |
| print(f"Moving {filename} to {first_digit}\\") | |
| shutil.move(source_file, dest_file) | |
| moved_count += 1 | |
| print() | |
| print(f"Done.") | |
| print(f"Moved: {moved_count}") | |
| print(f"Skipped: {skipped_count}") | |
| pause_exit() |