Skip to content

Instantly share code, notes, and snippets.

@Git-I985
Created October 18, 2023 17:00
Show Gist options
  • Save Git-I985/f0eee4a799bc0a3e38128b8faf244115 to your computer and use it in GitHub Desktop.
Save Git-I985/f0eee4a799bc0a3e38128b8faf244115 to your computer and use it in GitHub Desktop.
# step 1. find all uncommitted/changed images in sources dir and copy them to the buffer dir
for file in $(git status -s | cut -c4- | grep .png)
do
echo $file;
mkdir -p "./to_optimize/$(dirname $file)";
cp $file "./to_optimize/$file";
done
# step 2. optimize files in buffer dir by some third party service
# step 3. copy files from buffer dir back to the sources dir
for file in $(find "./to_optimize" -name "*.png")
do
cp $file ${file#"./to_optimize/"};
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment