I have following script (named vid2gif.sh) to convert a video file to gif:
#! /bin/bash
ffmpeg -i $1 /tmp/gif/out%04d.gif
gifsicle --delay=10 --loop /tmp/gif/*.gif > $2
I can convert a file using command:
vid2gif.sh myvid.mp4 myvid.gif
How can I make it to convert all mp4 files in a folder? That is, how can I make following command work:
vid2gif.sh *.mp4
The script should output files as *.gif. Thanks for your help.
.shextensions for executable scripts (as opposed to shell libraries intended to be invoked withsource) is bad form -- executable scripts define commands, and UNIX commands don't have extensions -- they're inherently language-agnostic, as the shebang line at the top defines how they're interpreted. See talisman.org/~erlkonig/documents/… for a longer discussion.#!/bin/bashare bash scripts, not POSIX sh scripts, so using.shextensions for them is misleading; many such scripts will break in surprising ways if run withsh somescript, which the extension implies is supported).chmod +xto mark it executable, yes. If you didn't want to install it for all users, but only for yourself, you might consider making a$HOME/bindirectory and adding that to yourPATH.