Skip to content

Instantly share code, notes, and snippets.

@Like4Schnitzel
Created March 24, 2024 09:17
Show Gist options
  • Save Like4Schnitzel/0e2624295090166f9ba940d292197473 to your computer and use it in GitHub Desktop.
Save Like4Schnitzel/0e2624295090166f9ba940d292197473 to your computer and use it in GitHub Desktop.
Python file splitter to get around discord size limits
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