sort files based on name

So i've got a giant list of files that all have a key number in them (1818 for example) and there's four files in the directory that all have that key number only ONCE somehwere in the filename. I'm trying to grab those three files and then create a new directory with that key number as the name and then move the four files into that directory.

I've also already got a list of the key numbers in my program, so thats good

I've kinda got an idea how to go about it...but I'd like a little direction to start with.

here's what a typical list of files looks like:

1
2
3
4
5
6
7
8
9
10
11
12
0x18FF_Readme.txt
0x1810_Readme.txt
0x1818_Readme.txt
2x18_micro_production_bootload_file_hid18FF.hex
2x18_micro_production_bootload_file_hid1810.hex
2x18_micro_production_bootload_file_hid1818.hex
2x18_module_epld_production_bootload_file_hid18FF.hex
2x18_module_epld_production_bootload_file_hid1810.hex
2x18_module_epld_production_bootload_file_hid1818.hex
PL5x_module_mdf_hid18FF.hex
PL5x_module_mdf_hid1810.hex
PL5x_module_mdf_hid1818.hex


so I'd like to group everything that has (18FF) into a directory called 18FF and so forth.

ideas? thanks guys
Last edited on
Try parsing the file names with a function like atoi().
Topic archived. No new replies allowed.