Open jsncrdnl opened 5 years ago
Hi @jsncrdnl
I'm using a shell script on top of gpup
in order to keep into count which files has been already uploaded. You can see it here.
The script will upload images recursively using the folder name as album name. And storing in a file which folders has been uploaded. So the next time you use the script only new images will be uploaded.
NOTE: My folder names has an specific template name YYYYMMDD: Description - Something
, the script is coded to remove the last part Something
in order to create the album name. You can configure this at this line
All my pictures are under a parent folder /home/paco/Pictures
and I only need to use my script as:
$ upload_to_Google_Photos.sh -d /home/paco/Pictures
HI @pacoorozco
Thank you for that script. It works great. But I have one Problem. The scripts skips the entire folder when the folder is uploaded. Therefore new files inside an existing folder are skipped too. Is there a way to modify your script so that new files inside an existing folder are recognized and uploaded?
Hi @Flipo
The script is optimized to use gpup
multiple uploads... for this reason it's working with folder granularity. It creates an album for every folder.
To track files uploads your should change several parts of the script to work file by file. There are many options, depending if you want to maintain folders as a albums or not.
It should look like this way
1) Remove lines 62-66
2) Change uploadDirectory
function
# Uploads a directory and creates a new album using `gpup`.
function uploadDirectory() {
local _dir; _dir=${1:-}
[[ -z "${_dir}" ]] && die -e 127 "No directory has been specified."
local _albumName
_albumName=$(basename "${_dir%-*}")
find "${_dir}" -mindepth 1 -maxdepth 1 -type f -print0 |
while IFS= read -r -d '' File; do
info "Processing ${File}"
# Check if directory was previously uploaded. Skip it if it was.
if keyIsInDatabase "${File}" "${uploadedFilesDatabase}"; then
debug " File was found in uploaded files database. Skipped!"
continue
fi
local _ret; _ret=0
debug "Command: ${GPUPBinary} --new-album \"${_albumName}\" \"${_File}\""
if [[ "${dryRunFlag}" -eq "0" ]]; then
${GPUPBinary} --new-album "${_albumName}" "${_File}"
_ret=$?
fi
done
return ${_ret}
}
I've found the upgrade in @gchangchen's fork to work well for this too. Saves a list of MD5's to a ~/.gpupcache
file and skips whenever files match => https://github.com/gchangchen/gpup/commit/88e3f29b74b8e47e0a5f1beb11eb63e6a5d57c77
It's a different approach than gpup
, but you can take a look to gphotos-uploader-cli
I'm using both :sweat_smile:
It looks like the tool is always re-uploading files even if they're already online. It'd be great to keep a log of already uploaded files (paths) to avoid re-uploading it.