Collection of Bash code snippets, mostly one liners, to ease file handling among other things
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

vor 3 Jahren
1234567891011121314151617181920212223242526272829
  1. # Collection of Bash code snippets, mostly one liners, to ease file handling among other things
  2. Collection of notes
  3. #### rename files to reverse order
  4. `N=1; ls -tr -1 *.jpg | tac | while read file; do mv "$file" "$N".jpg; N=$((N+1)); done`
  5. #### rotate all images using imagemagick
  6. `mogrify -rotate 180 *.jpg`
  7. `mogrify` overwrites existing images which is what makes it different from `convert`
  8. #### cut poly-shape out of image, crop image to its boundaries, fill surrounding holes in certain color or transparent (for all jpgs in folder)
  9. `for f in ./*.jpg; do convert "$f" \( -clone 0 -fill black -colorize 100 -fill white -draw "polygon 3276,2421 4945,2407 4956,4708 3287,4722" \) -alpha off -compose copy_opacity -composite -trim +repage 41050648/"$f"_left.jpg; done`
  10. #### do something inside each folder of this folder
  11. ```
  12. for d in */; do
  13. cd $d;
  14. for dir in */; do
  15. for frontpage in "$dir"*.jpg; do
  16. echo convert "$frontpage" -resize 500x500 "$frontpage"_500px.jpg
  17. break 1
  18. done
  19. done
  20. cd ..;
  21. done
  22. ```