I would like to rename files within each sub-directory by adding the name of the sub-directory. Following the answer from Rename files by adding their parent folder name, I tried:
rename 's/(.*)\//$1\/$1_/' */*
However for lots of sub-directories it doesn't work. I have 13,000 sub-directories each containing about 300 files. I get
-bash: /usr/bin/rename: Argument list too long
I tried:
ls | xargs rename 's/(.*)\//$1\/$1_/' */*
find . -maxdepth 1 -type f -print0 | xargs rename 's/(.*)\//$1\/$1_/' */*
Both give the same error:
-bash: /usr/bin/xargs: Argument list too long
EDIT
xargs -L rename 's/(.*)\//$1\/$1_/' */*
xargs -L1 rename 's/(.*)\//$1\/$1_/' */*
Same error:
-bash: /usr/bin/xargs: Argument list too long