#!/bin/sh

for txt in `find . -name "*.txt" ` 
do  
	echo "deleting $txt"
	rm -v $txt
done

for i in `find . -maxdepth 1 -mindepth 1 -type d ` 
do  
	echo "working on $i"
	PREFIX="$i/contents-"
	#PREFIX="test-" #for debugging
	find  $i -name '*.bz2'> "$PREFIX"all.txt ; 
	find  $i -name '*.nt.bz2' > "$PREFIX"nt.txt  
	find  $i -name '*.ttl.bz2' > "$PREFIX"ttl.txt 
	find  $i -name '*.nq.bz2' > "$PREFIX"nq.txt 
	find  $i -name '*.tql.bz2' > "$PREFIX"tql.txt 
	
	for file in `find $i -maxdepth 1 -mindepth 1 -name '*.txt' `
	do
		echo "changing $file"
		sed -i 's/^\.\//http:\/\/downloads.dbpedia.org\/3.8\//' $file
		
	done
	
done
