I have some files in a folder, which are named ***_code_c****
(where *
represents any letter or number). I have another folder that have many files, folders and subfolders inside it. What I want to do is to look for and copy to another location any files that matches the names of these files like ***_code_c****
but with only two letters different like this ***_mode_m****
and ***_kode_c****
and any of the files that matches this criteria will be copied to a specific folders where the ones having the mode
instead of code
will be placed in a folder and the ones having the kode
instead of code
will be placed in another folder. If anyone could please advise how this can be done. Thanks
Example to clarify what needs to be done:
FolderA
has some files in it lets say ABC_code_c001
, CDE_code_c002
, FGH_code_c003
...
Another FolderB
has many files, folders and subfolders inside it.
for every file in FolderA
there is a corresponding two files in FolderB
which are named exactly the same except for the middle part. For example the corresponding two files of ABC_code_c001
are ABC_kode_c001
and ABC_mode_m001
, while the corresponding
files of FGH_code_c003
will be FGH_kode_c003
and FGH_mode_m003
and so on
So, what I want to do is to take every file in FolderA
and search for the two corresponding files in FolderB
then copy each of these two files in two other folders lets say FolderC
and FolderD
(one in each).
Note that the names I'm using is not the exact names I listed in the example, but it has the same idea where the difference between its name and the two other names will be one letter in the middle from c
to k
and m
.