Maybe this is not the best piece of code but it works.
#Given a txt file, where the first colum is x, this script calculates
#the best fit for each column starting from column 2
#N=number of column
#(R0:R1)=range of x values over which calculate fit
#The script saves parameters fit in file parameters.txt.
#Remember to erase this file before relaunching because appends results.
N=28
R0=0
R1=7
do for [i=2:N:1] {
set terminal postscript enhanced color solid eps
set output graph(i)
set xrange[0:20]
f(x) = exp(-x/tau)
set fit errorvariables
fit [R0:R1] f(x) 'myfilename.txt' u 1:i via tau
set print "parameters.txt" append
print tau,tau_err
plot"myfilename.txt" u 1:i, f(x)
reset
}