CLI app made to manage files stored in Google Drive.
For this program to work you need to create a Google Service Account
Then go to a Common Drive
and give it , depending on your usage , the following perms:
- Content Manager -> to only manage files created by the same service account
- Manager -> to manage all files
To let the program access your account , please create a valid JWT for it. To do so:
- Go to Google Console
- APIs (to do left)
- Credentials
- Go to Service Accounts on the lower half
- Create a service account
- Click on it
- Go to keys tab
- Create a key and download it
- Rename it to
credentials.json
and move it to./res/
to be accessed by the program
# if you are on anything that uses pip
make set-up-win
# if you are on debian(the system that I developed on)
make set-up-debian
It is made to process files with the following format:
<DATE>_<TIME>_<FILE_NAME>.<EXTENSION>
To be more precise:
YYYY-MM-DD_HH-MM-SS_FILE.<something>
python3 src/main.py validate -d <drive_id> -f <folder_id>
-l <lifetime> -p <date_pattern> -g <glob_expression> -r <regex>
Flags explained:
-d/--driveId
-> specify the target drive that you want the process to run on-f/--folderId
-> specify the target folder from within a drive-l/--lifetime
-> set the max lifetime of the files that are not going to be deleted. You can disable lifetime check by setting it0
-p/--pattern
-> provide a pattern that is going to save files from being delete
For example:YYYY-MM-15
is going to except files that were created on the 15th day of any month and year-r/--regex
-> search by regular expression-g/--glob
-> search by glob expression--force
-> by default , the CLI asks you to confirm the files that are going to be deleted. By adding this flag , you can now peacefully run this command in your script
Example of a glob expression. Similar to the ones you use grep
/find
or anything with a file filtering process
# get any file that ends in FII_CODE.zip
*FII_CODE.zip
# gets any file that contains 03-
*03-*
# get any file that starts with 2025
2025*
Every flag specified above is optional. If a flag is not present , the it will get it's default value from:
./res/config.sh
To see all the variables in the config file , please use the following:
python3 src/main.py config --list
To set a variable from within the terminal, use:
python3 src/main.py config <VAR_1>=<VALUE_1> <VAR_2>=<VALUE_2> ...
# you can list as much as you like
- if you are in ASII and need some features , ask me or request to make you a collaborator
- contact me or Frunza Alexandru if you have a problem with setting up a Service Account
- if you develop on a different system , please add the set-up as a rule in the
makefile
- modify the
CONFIG_PATH
variable inconfig.py
to adjust the defaultconfig.sh
search path