user3718237
user3718237

Reputation:

Copy a range of folders in command line

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./

Upvotes: 1

Views: 1107

Answers (2)

ohmu
ohmu

Reputation: 19752

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./

Upvotes: 1

Marcus Müller
Marcus Müller

Reputation: 36347

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.

Upvotes: 0

Related Questions