I had some text files I deleted acidentally. I want to recover them and I know the filename, but as they are all alike inside I can't use foremost or scalpel. The testdisk recovers the files but without the original filename so it's useless. Any help?
testdisk has multiple modes of operation, and I think in simple mode it just does a sector-by-sector scan of the disk looking for things that look like files.
You'll want to follow to the letter this guide, which details going into advanced mode and then selecting the desired partition.
The ability to recover the filename from a deleted file depends on the filesystem used.
In FAT filesystems (including, I believe, FAT32) when a file is deleted the first character of its filename is overwritten and thus can't be recovered, but the rest of the filename can. When testdisk recovers a deleted file on a FAT filesystem, it substitutes the missing first letter with an underscore. So after recovery with testdisk (assuming you chose the right mode), instead of looking for "myfile.txt" you'll want to look for "_yfile.txt". I'm not sure what testdisk does for multiple files that have identical names from the second letter onwards.
Note that testdisk is designed for use on an entire partition or drive at once and it's designed to be able to recover from a partition you can no longer mount, so when it recovers files it doesn't recover them in-place, it must recover them to a separate drive.