I need to take the first three letters of a filename and set it into a text file, in a certain fashion. How can I do this?

Posted by JuniorD on Super User See other posts from Super User or by JuniorD
Published on 2012-09-11T08:30:59Z Indexed on 2012/09/11 9:41 UTC
Read the original article Hit count: 220

Filed under:

Okay, so I need to take the first three letters of a file from a list of files, and place this into a text file in a certain manner. I will provide examples below.

Lets say that I have two file names in the same directory, one called cougar.txt and the other bear.txt. These are in the animals directory. I need to take the first three letters of these words, and transpose them into a text file along with the directory, in the following format:

BEA = "animals/bear.txt"

COU = "animals/cougar.txt"

This should happen with any random thing that might be in the list. I'm fairly new to this sort of coding, so I'm not quite sure which language to use, and I'm learning as I go. This new challenge seems fairly daunting to me, and I would be much appreciated if you guys could help.

Also, I'm using Windows 7. Been attempting at this all day, to no avail. Preferably done in batch, but if that is impossible I'm open to recommendations.

© Super User or respective owner

Related posts about batch