{"id":2567,"date":"2010-06-04T13:32:22","date_gmt":"2010-06-04T13:32:22","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/2010\/06\/04\/matlab-for-file-management\/"},"modified":"2010-06-04T13:32:22","modified_gmt":"2010-06-04T13:32:22","slug":"matlab-for-file-management","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2010\/06\/04\/matlab-for-file-management\/","title":{"rendered":"MATLAB for File Management"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/15007\">Jiro<\/a>'s pick this week is a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/12-central-diff-m-fileseries-rename-renumber-files-recursive-directories\">set of functions for operating on files and folders<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/20315\">Frederic Moisy<\/a>.\r\n   <\/p>\r\n   <p>I use MATLAB for analyzing data and creating tools for data analysis. But I like MATLAB so much that I use it for things other\r\n      than regular work stuff. That's why when I came across Frederic's entry, it made me smile. This would certainly help me manage\r\n      my files on my computer. With his collection of files, you can easily navigate to folders, manage folders, and view\/manipulate\r\n      file names.\r\n   <\/p>\r\n   <p>To get the file names of my image files in \"image1\" and \"image2\",<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">rdir(<span style=\"color: #A020F0\">'image*\/*.jpg'<\/span>)<\/pre><pre style=\"font-style:oblique\">    'image1\\im001.jpg'\r\n    'image1\\im002.jpg'\r\n    'image1\\im003.jpg'\r\n    'image1\\im004.jpg'\r\n    'image1\\im005.jpg'\r\n    'image1\\im006.jpg'\r\n    'image2\\im018.jpg'\r\n    'image2\\im019.jpg'\r\n    'image2\\im020.jpg'\r\n    'image2\\im021.jpg'\r\n    'image2\\im022.jpg'\r\n<\/pre><p>To rename my image files by replacing certain text patterns,<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">cd <span style=\"color: #A020F0\">image1<\/span>\r\nrenamefile(<span style=\"color: #A020F0\">'*.jpg'<\/span>, <span style=\"color: #A020F0\">'im'<\/span>, <span style=\"color: #A020F0\">'newIm'<\/span>);\r\ncd <span style=\"color: #A020F0\">..\/image2<\/span>\r\nrenamefile(<span style=\"color: #A020F0\">'*.jpg'<\/span>, <span style=\"color: #A020F0\">'im'<\/span>, <span style=\"color: #A020F0\">'oldIm'<\/span>);\r\ncd <span style=\"color: #A020F0\">..<\/span>\r\nrdir(<span style=\"color: #A020F0\">'image*\/*.jpg'<\/span>)<\/pre><pre style=\"font-style:oblique\">    'image1\\newIm001.jpg'\r\n    'image1\\newIm002.jpg'\r\n    'image1\\newIm003.jpg'\r\n    'image1\\newIm004.jpg'\r\n    'image1\\newIm005.jpg'\r\n    'image1\\newIm006.jpg'\r\n    'image2\\oldIm018.jpg'\r\n    'image2\\oldIm019.jpg'\r\n    'image2\\oldIm020.jpg'\r\n    'image2\\oldIm021.jpg'\r\n    'image2\\oldIm022.jpg'\r\n<\/pre><p>One suggestion I have is for \"renamefile\" to work with multiple folders at once. But it's pretty useful as it is!<\/p>\r\n   <p><b>Comments<\/b><\/p>\r\n   <p>Let us know what you think <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=2567#respond\">here<\/a>.\r\n   <\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_5482054a5e1a4b1facb576e61a486736() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='5482054a5e1a4b1facb576e61a486736 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 5482054a5e1a4b1facb576e61a486736';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        author = 'Jiro Doke';\r\n        copyright = 'Copyright 2010 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n      \r\n      d.title = title + ' (MATLAB code)';\r\n      d.close();\r\n      }   \r\n      \r\n-->\r\n<\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_5482054a5e1a4b1facb576e61a486736()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n            the MATLAB code \r\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; 7.10<br><\/p>\r\n<\/div>\r\n<!--\r\n5482054a5e1a4b1facb576e61a486736 ##### SOURCE BEGIN #####\r\n%%\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/15007\r\n% Jiro>'s pick this week is a <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/12-central-diff-m-fileseries-rename-renumber-files-recursive-directories \r\n% set of functions for operating on files and folders> by\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/20315\r\n% Frederic Moisy>.\r\n%\r\n% I use MATLAB for analyzing data and creating tools for data analysis.\r\n% But I like MATLAB so much that I use it for things other than regular\r\n% work stuff. That's why when I came across Frederic's entry, it made me\r\n% smile. This would certainly help me manage my files on my computer. With\r\n% his collection of files, you can easily navigate to folders, manage\r\n% folders, and view\/manipulate file names.\r\n%\r\n% To get the file names of my image files in \"image1\" and \"image2\", \r\n\r\nrdir('image*\/*.jpg')\r\n\r\n%%\r\n% To rename my image files by replacing certain text patterns,\r\n\r\ncd image1\r\nrenamefile('*.jpg', 'im', 'newIm');\r\ncd ..\/image2\r\nrenamefile('*.jpg', 'im', 'oldIm');\r\ncd ..\r\nrdir('image*\/*.jpg')\r\n\r\n%%\r\n% One suggestion I have is for \"renamefile\" to work with multiple folders\r\n% at once. But it's pretty useful as it is!\r\n%\r\n% *Comments*\r\n%\r\n% Let us know what you think\r\n% <https:\/\/blogs.mathworks.com\/pick\/?p=2567#respond here>.\r\n\r\n##### SOURCE END ##### 5482054a5e1a4b1facb576e61a486736\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n   Jiro's pick this week is a set of functions for operating on files and folders by Frederic Moisy.\r\n   \r\n   I use MATLAB for analyzing data and creating tools for data analysis. But I like MATLAB... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2010\/06\/04\/matlab-for-file-management\/\">read more >><\/a><\/p>","protected":false},"author":35,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2567"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=2567"}],"version-history":[{"count":0,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2567\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=2567"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=2567"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=2567"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}