DriveSync is a Java application that synchronizes a local folder with a folder in your Google Drive.
- Java 11 or newer
- Google account
- Go to the Google Cloud Console.
- Create a new project (or select an existing one).
- Enable the Google Drive API for your project.
- In the sidebar, go to APIs & Services > Credentials.
- Click Create Credentials > OAuth client ID.
- Choose Desktop app as the application type.
- Download the generated
credentials.jsonfile.
- Copy your downloaded
credentials.jsonfile into the following directory in your project:src/main/resources/credentials.json - If you are running the packaged
.jar, placecredentials.jsonin the same directory as the.jarfile, or ensure it is included in the JAR's resources.
Use your preferred build tool (e.g., Maven or Gradle) to build the project and create the .jar file.
Run the application from the command line, providing the local folder path and the Google Drive folder name as arguments:
java -jar DriveSync.jar <local_folder_path> <google_drive_folder_name><local_folder_path>: The path to the folder on your computer you want to sync.<google_drive_folder_name>: The name of the folder in your Google Drive to sync with.
- On first run, a browser window will open asking you to authorize the app to access your Google Drive.
- After authorization, tokens will be saved in a
.drivesync_tokensdirectory in your user home for future use.
This project includes helper scripts in the scripts/ directory to help you run DriveSync automatically when you log in to Windows:
-
start-drivesync.bat
A batch file that launches the DriveSync application with your desired arguments. -
launch-drivesync.vbs
A VBScript that launches the batch file silently (without showing a Command Prompt window).
-
Edit
start-drivesync.bat- Update the paths and arguments inside the script to match your setup (Java path, JAR location, local folder, and Google Drive folder name).
-
Edit
launch-drivesync.vbs- Make sure the path to
start-drivesync.batis correct.
- Make sure the path to
-
Copy
launch-drivesync.vbsto your Startup folder:C:\Users\<YourUsername>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\StartupThis will run DriveSync automatically and silently every time you log in.
Do NOT share your credentials.json file or commit it to any public repository.
This file contains sensitive information unique to your Google Cloud project.
- If you see a
NullPointerExceptionrelated tocredentials.json, make sure the file is present in the correct directory. - If you change your Google Drive folder name, you must re-run the app with the new name.
- If the app does not run at startup, check your log files and ensure all paths and permissions are correct.