I have some arbitrary files in a directory "my_directory":
each with some value.
In Matlab, I have an array of values, call it "my_array"
I want to check whether the file value is within 10 of a value in my array. Then, if so, I want to rename the file.
For example, file_1002.txt has a value of 1002, which is within 10 of values in my_array (namely 1000 and 1010). Therefore, file_1002.txt will be renamed file_1002_new.txt. Likewise, for 1012 and 2045. However, file_1023.txt has a value of 1023, which is not within 10 of any values in my_array, so file_1023.txt does not need to be renamed.
How could this scheme be accomplished? I am dealing with many files in my_directory and many values in my_array, so a quicker solution would be more optimal. Thanks!