{"id":272,"date":"2020-06-13T21:11:12","date_gmt":"2020-06-13T21:11:12","guid":{"rendered":"https:\/\/molecularsciences.org\/content\/?p=272"},"modified":"2020-12-14T00:45:31","modified_gmt":"2020-12-14T00:45:31","slug":"bash-batch-renaming-file-extensions","status":"publish","type":"post","link":"https:\/\/molecularsciences.org\/content\/bash-batch-renaming-file-extensions\/","title":{"rendered":"bash: Batch Renaming File Extensions"},"content":{"rendered":"\n<p>Suppose I need to change the file extensions of certain files in a directory.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\necho \"Please specify a directory: \"\nread folder\ncd $folder\nfor i in *.txt\n    do\n    mv \"$i\" `basename $i txt`fasta\ndone<\/code><\/pre>\n\n\n\n<p>The directory address specified by the user is read into the script in line 2. This address is used to cd to the directory. This script changes the extensions of .txt files to .fasta.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Suppose I need to change the file extensions of certain files in a directory. The directory address specified by the user is read into the script in line 2. This address is used to cd to the directory. This script changes the extensions of .txt files to .fasta.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101,34],"tags":[94,35],"class_list":["post-272","post","type-post","status-publish","format-standard","hentry","category-bash","category-linux","tag-bash","tag-linux"],"_links":{"self":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/272","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/comments?post=272"}],"version-history":[{"count":1,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/272\/revisions"}],"predecessor-version":[{"id":273,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/272\/revisions\/273"}],"wp:attachment":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/media?parent=272"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/categories?post=272"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/tags?post=272"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}