Created
March 24, 2024 09:17
-
-
Save Like4Schnitzel/0e2624295090166f9ba940d292197473 to your computer and use it in GitHub Desktop.
Python file splitter to get around discord size limits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
maxBytes = 25000000 # max size of a split file part in bytes | |
if len(sys.argv) > 1: | |
filePath = sys.argv[1] | |
else: | |
filePath = input("Enter the path to a file: ") | |
with open(filePath, "rb") as f1: | |
i = 0 | |
while (read_bytes := f1.read(maxBytes)): | |
with open(f"{filePath}.part{i}", "wb") as f2: | |
f2.write(read_bytes) | |
i += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment