This script allows you to automatically download all your GitHub project files from their respective repositories. It is specifically designed to work with repositories listed in a remote README.md file, where each repository is specified in a bullet point format.
- Fetches a remote
README.mdfile containing a list of repositories. - Parses the repository names from the
README.mdfile. - Generates URLs to download project files directly from the
mainbranch. - Downloads project files to the current working directory.
- Provides feedback for each download process.
- Python 3.x
The script uses the following built-in Python modules:
osurllib.requestrequestshttp.clienturllib.parse
No external modules are required for this script.
- Clone or copy this script to your local machine.
- Ensure you have Python 3.x installed.
-
Edit the script to point to the correct remote
README.mdfile by modifying theurlvariable:url = "https://raw.githubusercontent.com/your-username/your-repo/refs/heads/main/README.md"
Replace
your-usernameandyour-repowith the appropriate GitHub username and repository. -
Run the script using the following command:
python kproject-updater.py
-
The script will:
- Fetch the remote
README.mdfile. - Parse the project names from the file.
- Generate download URLs for each project.
- Download the respective
.pyfiles into the current working directory.
- Fetch the remote
- Fetches the remote
README.mdfile using the provided URL. - Parses the file to extract lines starting with a dash (
-) to identify project names. - Generates download URLs for each project based on a consistent naming convention.
- Downloads the project files using
urlretrieve. - Saves each file to the current script directory.
- Displays the generated URLs for each project.
- Confirms successful download or reports errors for individual files.
Example:
project1 : https://raw.githubusercontent.com/username/project1/refs/heads/main/project1.py
Downloaded project1.py successfully!
project2 : https://raw.githubusercontent.com/username/project2/refs/heads/main/project2.py
Downloaded project2.py successfully!
All Projects Are Updated.- Assumes all repositories use the same naming convention for their
.pyfiles (i.e.,<repository_name>.py). - Relies on the structure and format of the remote
README.mdfile.
To customize the script:
- Modify the
urlvariable to point to your ownREADME.mdfile. - Update the
generate_urlsfunction if your project file naming conventions differ.