I have a parent directory composed of a set of sub-directories. Each sub-directory is composed of a list of files.
Here is the scenario:
v_1:
filenames.txt
v_2:
labels.txt
v_3:
coding.txt
What is my expected output?
v_1:
v_1_filenames.txt
v_2:
v_2_labels.txt
v_3:
v_3_coding.txt
What l have tried to solve that?
rename -n 's/(.*)\//$1\/$1_/' */*
which prints
rename(v_1/filenames.txt, v_1/v_1_filenames.txt)
rename(v_2/labels.txt, v_2/v_2_labels.txt)
rename(v_3/coding.txt, v_3/v_3_coding.txt)
However it doesn't work. To confirm that I did:
ls *
and I get:
v_1:
filenames.txt
v_2:
labels.txt
v_3:
coding.txt
Any cue? Thank you
Simply remove the option
-n
. Fromman prename
*:* There are multiple commands called
rename
; I assume you're usingprename
on Ubuntu 16.04 or earlier, though option-n
does the same thing for most other versions. For details see What's the difference between the different "rename" commands?