2

I'd like to know if it is possible to duplicate a single file to multiple files with a different list of arguments. I have a generic image and I need to make multiple copies of it adding a different country extension to each copy.

I tried optimistically:

cp -r centre-stage-synopsis.jpg centre-stage-synopsis-{en_US,fr_FR,de_DE,da_DK,ru_RU,pt_BR,ro_RO,hu_HU,el_GR,it_IT}.jpg

But it doesn't work. Is there a way to do this in one go?

Cheers

terdon
  • 54,564

2 Answers2

7

Not sure if zsh allows this, so please feel free to smack me if the syntax is significantly off that you can't figure out how to translate this.

I am going to post a code fragment that should do what you want from either the sh, dash, or bash shells (basically anything from the Bourne family).

for i in en_US fr_FR de_DE da_DK ru_RU pt_BR ro_RO hu_HU el_GR it_IT; do cp -r centre-stage-synopsis.jpg centre-stage-synopsis-$i.jpg; done

Good luck, and as I said, smack me if zsh doesn't like it. :)

allquixotic
  • 34,882
4

If you have multios and brace_expand enabled (they should be on by default) you can do it with cat:

cat centre-stage-synopsis.jpg \
  >centre-stage-{en_US,fr_FR,de_DE,da_DK,ru_RU,pt_BR,ro_RO,hu_HU,el_GR,it_IT}.jpg
Thor
  • 6,763
  • 1
  • 40
  • 44