This is simple and has been asked/answered many times but not when files are in different directories. I want to do this: Renaming part of a filename, but with the files in different sub-directories.
This is what I've tried:
for f in */*run?.t; do mv -i -- "$f" "${f//subset/subset5}"; done
but it tries to rename the directory too (because subset is also in the directory name) and then errors because that directory name is not found. What am I missing?
Here is the general directory structure:
Gene1_subset/
Gene1file_subset.run1.t
Gene1file_subset.run2.t
Gene2_subset/
Gene2file_subset.run1.t
Gene2file_subset.run2.t
Here is what I'd like:
Gene1_subset/
Gene1file_subset5.run1.t
Gene1file_subset5.run2.t
Gene2_subset/
Gene2file_subset5.run1.t
Gene2file_subset5.run2.t
But it attempts to rename the directories too so you get the error:
cannot move Gene1_subset/Gene1file_subset.run1 to Gene1_subset5/Gene1file_subset5.run1 : No such file or directory