Good afternoon, I would like to ask the developers, so in a future release, please add the option to delete a file or directory by name, because working with script and this option would greatly reduce the number of lines and jerry-rig to make the script runs as it should.
Another option I would like to ask if it were possible is a parameter like grive2, --no-remote-new that prevents the creation of the same directory on a new upload and overwrites its contents.
Thanks in advance.
T谩cio Andrade
deletebyFileName.sh
#!/bin/sh
name = $1
if [ -z "$name"]
then
echo You have to enter file name to search
fi
gdrive list -q "name contains '${name}'" -m 100 --order name | sed -rn 's/([0-9A-Za-z_\-]+)\s.*/\1/p' > list.log
while IFS='' read -r line || [[ -n "$line" ]]; do
gdrive delete "${line}"
done < list.log
rm -rf list.log
echo -ne "Fin"
./deletebyFileName.sh ".mkv"
Thank you! In the case of this environment I am using Windows Server! My goal is to use a push client to avoid ransomware .... Previously I used megatools, but this client hired a 100GB Google Drive account and asked him to find a compatible client.
Would you know how to do this using CMD or PowerShell?
Needs to skip the first line in the file log since it's "Id" and gives off an error because the fileId is obviously non existant, but it is a nice base.
This is how I modified it:
#!/bin/bash
name=$1
if [ -z "$name" ]
then
echo You have to enter file name to search
exit
fi
/home/user/gdrive list -q "name contains '${name}'" -m 100 --order name | sed -rn 's/([0-9A-Za-z_\-]+)\s.*/\1/p' > /tmp/glist.log
while IFS='' read -r line || [[ -n "$line" ]]; do
/home/user/gdrive delete "${line}"
done < /tmp/glist.log
rm -rf /tmp/glist.log
Not so expert about shell scripting so no idea for now about removing first line of output, but not having an exit in the parameter check will lead to basically remove every file in google drive :open_mouth:
Ask me how I found out :tongue:
Luckily it was just a testing config
Most helpful comment
deletebyFileName.sh
./deletebyFileName.sh ".mkv"