1

I found this link with an example of how I can actually copy range of files https://serverfault.com/questions/370403/copy-a-range-of-files-in-command-line-zsh-bash, using this

$cp P10802[75-83].JPG ~/Images/.

Is there any way I can also copy range of folders or directory?

Maybe something like this $cp -r folder[001-999] ~/images./

Community
  • 1
  • 1

2 Answers2

1

Use the -R flag to recursive copy the directories. According to Can I use shell wildcards to select filenames ranging across double-digit numbers, you can use the syntax {start..end} to match a number range. Putting that together would give you:

cp -R folder{001..999} ~/images./
Community
  • 1
  • 1
Uyghur Lives Matter
  • 18,820
  • 42
  • 108
  • 144
0

Yes, using the same logic. Globbing and expansion (which is what bash uses to generate the individual names out of these patterns) work on files as well as on directory names.

Marcus Müller
  • 34,677
  • 4
  • 53
  • 94
  • Yes, but this worked as files only when i tried it, i didn't work for folders –  Feb 24 '15 at 15:58
  • Then you have a typo or are not using the right command. Bash doesn't make a difference between names that point to directories and names that point to files. – Marcus Müller Feb 24 '15 at 16:14