Moin,
how do you assign the filenames in the directory to the according filenames in names.txt? Simply by the position in the "ls" output?
In this case you can do it like this:
1. create a file with the filename's list:
2. merge the two files:
Code:
paste /tmp/list.txt /tmp/names.txt
You get the following 2 column output:
Code:
jan@jack:~/tmp> paste -d " " /tmp/list.txt /tmp/names.txt
1.txt one.txt
2.txt two.txt
3.txt three.txt
3. Now you can use this output to rename the files:
Code:
paste -d " " /tmp/list.txt /tmp/names.txt | while read line; do
mv $line
done
The filenames may not contain spaces or tabs!
Jan