Skip to content

Instantly share code, notes, and snippets.

@gergelypolonkai
Created June 12, 2014 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gergelypolonkai/6c6438cdc6cd0b7b781e to your computer and use it in GitHub Desktop.
Save gergelypolonkai/6c6438cdc6cd0b7b781e to your computer and use it in GitHub Desktop.
#! /bin/bash
#
# A generalised converter to convert all files of
# a given extension in a directory to another
# type.
#
# I simply assume that yourConverter can detect
# the input files' type, and figure out the
# destination type from $ext_out
ext_in=doc
ext_out=txt
# Set the input field separator to newline only.
# This is required if you have at least one file
# with a space in its name.
IFS='
'
for i in `ls -1 *.$ext_in`
do
o="${i%$ext_in}$ext_out"
yourConverter -i "$i" -o "$o"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment