Quick linux tip:

To copy/move multiple files via terminal, use:

cp source/{file1.txt, random.jpg ..} destination/

This comes in handy when your file names do not follow a common naming convention, i.e. when asterisk (*) is not usable.

  • 4
    I love curly brackets in terminal. They can do so much stuff, like number ranges ( {1..5} for example)
  • 12
    And then for a Windows solution, install linux!
  • 5
    A couple of nuances about this shell extension:

    - does not play well with quotes, so if you have a path with spaces -- you'll have to escape them;

    - harder to read/maintain when scripted;

    - to double-check why the file name does not autocomplete you'll have to rewrite the full path to parent directory for 'ls';

    - non-POSIX, so bourne shell, dash, ksh, etc do not support that;

    - etc..

    It's a nice extension but use it with caution -- do not get used to it as other shells might drown you by not supporting it.

    IMO better way is to:

    cd workdir/some/project/you/are/working/on/

    cd /directory/with/files

    cp -rp file1 file2 file3.jpg /media/thumbdrive/ ## r -- resursively, p -- do not change timestamps and ownership, permissions

    cd - ## dash returns to ${OLDPWD}
  • 3
    @mrsulfat or just use git bash. it should be able to do this too. (don't have time to test it right now though)
  • 2
    @hasu if you have windows, wont you just use drag and drop from folder to folder? Seems better that writing a line fill with the crap names I call filles!
  • 0
    You can't put a space after the comma
  • 0
    man, there is a built-in way to move multiple files with `cp`...

    just do so:

    `cp -t <target/directory> <file/to/copy> [file2 [file3 [...] ] ]`
Add Comment