diff --git a/chertex.sh b/chertex.sh index 505f57c..51c58b1 100755 --- a/chertex.sh +++ b/chertex.sh @@ -144,12 +144,15 @@ if [ $# -eq 1 ]; then # if $asset contains a space, the second element should be considered a local target folder for the copy operation # https://www.tutorialkart.com/bash-shell-scripting/bash-split-string/ # https://stackoverflow.com/a/30212526 - IFS=' ' # reset IFS + # Using space as separator was not working if the path contains spaces + # (I tried surrounding each path with "" or escaping each space with backslash, did not help) + # Rather than rewriting this part, I'll change to an IFS char that's unlikely to clash with any path specification. This way, spaces in paths should not need any changes. + IFS='>' # reset IFS # asset is read into an array as tokens separated by IFS read -ra asset_array <<< "$asset" # sanity check for array length if [ ${#asset_array[@]} -gt 2 ]; then - echo " Cannot handle more than one space per line" + echo " Cannot handle more than one $IFS character per line" echo " Terminating..." simpledelay.sh 2 exit 1 @@ -189,15 +192,16 @@ if [ $# -eq 1 ]; then photoslastrun="$path_thesis/assets/photos/.lowres/lastrun" if [ ! -f "$photoslastrun" ]; then # if, for some reason, the lastrun file does not exist - # copy over everything and then create the file - rsync -av "$path_thesis/assets/photos/" "$path_thesis/assets/photos/.lowres/" --exclude ".lowres/" + # copy over everything and then create the file + # (except for the .lowres tree itself, and any assets.external files) + rsync -av "$path_thesis/assets/photos/" "$path_thesis/assets/photos/.lowres/" --exclude ".lowres/" --exclude "assets.external" touch "$photoslastrun" fi # Detect new photos and copy them into .lowres tree # https://stackoverflow.com/questions/9612090/how-to-loop-through-file-names-returned-by-find # https://stackoverflow.com/questions/5241625/find-and-copy-files cd "$path_thesis/assets/photos" - find . -type f -cnewer $photoslastrun ! -path "./.lowres/*" -print -exec cp --parents "{}" .lowres \; + find . -type f -cnewer $photoslastrun ! -path "./.lowres/*" ! -name "*.external" -print -exec cp --parents "{}" .lowres \; # revert the effects of cd above. Redirect to null suppresses the output. cd - >/dev/null # Convert all non-JPG images (except for PDF, SVG, and other non-images) to JPG