1

I have a list with 1850 completely different names, like happy_birthday.js. Now I want to duplicate that file 1850 times, but each file must have a different name, coming from a list. This list is in the file song_titles.txt.

I know how to create folders from a list, like this:

xargs -tI % mkdir % < song_titles.txt

but I don't know if it is possible to combine renaming with duplicating.

Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
  • 1
    What shell are you using? – Benjamin W. Aug 16 '18 at 13:28
  • Mac OSX Yosemite – Jan de Vries Aug 16 '18 at 13:55
  • 1
    I don't quite understand what exactly you refer to when saying "list" and "file". Can you [edit] your question to add a [mcve], i.e., an example directory structure, contents of the various files etc.? – Benjamin W. Aug 16 '18 at 13:57
  • WIth the 'list' I mean "song_titles.txt" Contents of this list is something like: – Jan de Vries Aug 16 '18 at 14:16
  • 1
    Please update the question, it's hard to read things in comments as they lack most formatting. – Benjamin W. Aug 16 '18 at 14:17
  • song_titles.txt has vertically listed 1850 song titles and I have 1 file that has javascript content. I want 1850 times the same content, but each file have a different name. These names have to come from song_titles.txt. So if it were to have 2 songs instead of 1850, there would be created 2 files with 2 different names, but with the same content. – Jan de Vries Aug 16 '18 at 14:22
  • 1
    Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/178145/discussion-between-benjamin-w-and-jan-de-vries). – Benjamin W. Aug 16 '18 at 14:23

1 Answers1

1

When cp duplicates a file it can rename it to anything you like. Try:

xargs -tI % cp -- happy_birthday.js % <song_titles.txt
pjh
  • 6,388
  • 2
  • 16
  • 17