Move multiple files from command line

Using find to copy or move multiple files

All the .txt files are located in directories and subdirectories of the ~/tmp folder and I want to copy them to ~/tmp2

To copy them, open a Terminal and use;

$ find ~/tmp -name ‘*.txt’ -exec cp ‘{}’ ~/tmp2 \;

This copies all the files in the original folders and sub folders and saves them to the ~/tmp2 folder.

or to move them,

$ find ~/tmp -name ‘*.txt’ -exec mv ‘{}’ ~/tmp2 \;

this deletes them from the original folders and sub folders and saves them to the ~/tmp2 folder.

About these ads

Tags: , , , , , , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.

%d bloggers like this: