Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question
1  
On a side-note: Why do you want to keep so many copies of a single image? Wouldn't symlinks be better? –  Dennis Jul 26 '12 at 17:47
    
It's a bit of a contrived example. I need various copy of the same image to be used wit site locales. Normally images would be different, but on this occasion they are the same. Just the system needs them. –  Yannick Schall Jul 26 '12 at 18:22
add comment

2 Answers

up vote 6 down vote accepted

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. :)

share|improve this answer
1  
This works just fine in zsh. The -r switch is obsolete though. –  Dennis Jul 26 '12 at 17:50
    
I wasn't sure why the OP was insisting on the -r flag myself, but I figured I'd just blindly copy the structure/contents of his example into a proper for loop so that he could see what I did without me throwing him a curveball. He should be able to compare his ill-fated incantation with mine and see exactly what I did with his original code. –  allquixotic Jul 26 '12 at 17:53
    
I'm quite certain it was parts of the "optimistic attempt" to expand the insides of the brackets. –  Dennis Jul 26 '12 at 17:56
    
+1 for "ill-fated incantation" :) –  terdon Aug 17 '12 at 19:03
add comment

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
share|improve this answer
    
I love you people!!! –  Yannick Schall Jul 26 '12 at 18:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.