{"id":8154,"date":"2019-01-14T19:52:45","date_gmt":"2019-01-14T19:52:45","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw92\/?p=8154"},"modified":"2019-01-24T03:18:56","modified_gmt":"2019-01-24T03:18:56","slug":"how-to-move-multiple-file-types-simultaneously-from-commandline","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/01\/14\/how-to-move-multiple-file-types-simultaneously-from-commandline\/","title":{"rendered":"How To Move Multiple File Types Simultaneously From Commandline"},"content":{"rendered":"<p>The other day I was wondering how can I move (not copy) multiple file types from directory to another. I already knew how to\u00a0<a href=\"https:\/\/www.ostechnix.com\/find-copy-certain-type-files-one-directory-another-linux\/\" target=\"_blank\" rel=\"noopener\"><strong>find and copy certain type of files from one directory to another<\/strong><\/a>. But, I don\u2019t know how to move multiple file types simultaneously. If you\u2019re ever in a situation like this, I know a easy way to do it from commandline in Unix-like systems.<\/p>\n<h4 class=\"fittexted_for_content_h4\">Move Multiple File Types Simultaneously<\/h4>\n<p>Picture this scenario.You have multiple type of files, for example .pdf, .doc, .mp3, .mp4, .txt etc., on a directory named\u00a0<strong>\u2018dir1\u2019<\/strong>. Let us take a look at the dir1 contents:<\/p>\n<pre><strong>$ ls dir1<\/strong>\r\nfile.txt image.jpg mydoc.doc personal.pdf song.mp3 video.mp4<\/pre>\n<p>You want to move some of the file types (not all of them) to different location. For\u00a0 example, let us say you want to move doc, pdf and txt files only to another directory named\u00a0<strong>\u2018dir2\u2019<\/strong>\u00a0in one go.<\/p>\n<p>To copy .doc, .pdf and .txt files from dir1 to dir2 simultaneously, the command would be:<\/p>\n<pre>$ mv dir1\/*.{doc,pdf,txt} dir2\/<\/pre>\n<p>It\u2019s easy, isn\u2019t it?<\/p>\n<p>Now, let us check the contents of dir2:<\/p>\n<pre><strong>$ ls dir2\/<\/strong>\r\nfile.txt mydoc.doc personal.pdf<\/pre>\n<p>See? Only the file types .doc, .pdf and .txt from dir1 have been moved to dir2.<\/p>\n<p><a class=\"\" title=\"\" href=\"http:\/\/www.ostechnix.com\/wp-content\/uploads\/2019\/01\/mv-command.gif\" data-rel=\"lightbox-image-0\" data-rl_title=\"\" data-rl_caption=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-16249 tc-smart-load-skip tc-smart-loaded\" src=\"http:\/\/www.ostechnix.com\/wp-content\/uploads\/2019\/01\/mv-command.gif\" alt=\"mv command\" width=\"744\" height=\"441\" \/><\/a><\/p>\n<p>You can add as many file types as you want to inside curly braces in the above command to move them across different directories. The above command just works fine for me on Bash.<\/p>\n<p>Another way to move multiple file types is go to the source directory i.e dir1 in our case:<\/p>\n<pre>$ cd ~\/dir1<\/pre>\n<p>And, move file types of your choice to the destination (E.g dir2) as shown below.<\/p>\n<pre>$ mv *.doc *.txt *.pdf \/home\/sk\/dir2\/<\/pre>\n<p>To move all files having a particular extension, for example\u00a0<strong>.doc\u00a0<\/strong>only, run:<\/p>\n<pre>$ mv dir1\/*.doc dir2\/<\/pre>\n<p>For more details, refer man pages.<\/p>\n<pre>$ man mv<\/pre>\n<p>Moving a few number of same or different file types is easy! You could do this with couple mouse clicks in GUI mode or use a one-liner command in CLI mode. However, If you have thousands of different file types in a directory and wanted to move multiple file types to different directory in one go, it would be a cumbersome task. To me, the above method did the job easily! If you know any other one-liner commands to move multiple file types at a time, please share it in the comment section below. I will check and update the guide accordingly.<\/p>\n<p>And, that\u2019s all for now. Hope this was useful. More good stuffs to come. Stay tuned!<\/p>\n<p>Cheers!<\/p>\n<p><a href=\"https:\/\/www.ostechnix.com\/how-to-move-multiple-file-types-simultaneously-from-commandline\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The other day I was wondering how can I move (not copy) multiple file types from directory to another. I already knew how to\u00a0find and copy certain type of files from one directory to another. But, I don\u2019t know how to move multiple file types simultaneously. If you\u2019re ever in a situation like this, I &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/01\/14\/how-to-move-multiple-file-types-simultaneously-from-commandline\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How To Move Multiple File Types Simultaneously From Commandline&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-8154","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/8154","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=8154"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/8154\/revisions"}],"predecessor-version":[{"id":8650,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/8154\/revisions\/8650"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=8154"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=8154"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=8154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}