{"id":6321,"date":"2022-06-15T11:02:27","date_gmt":"2022-06-15T10:02:27","guid":{"rendered":"https:\/\/solidt.eu\/site\/?p=6321"},"modified":"2022-07-25T08:35:40","modified_gmt":"2022-07-25T07:35:40","slug":"powershell-recursive-rename-files-javascript-to-typescript","status":"publish","type":"post","link":"https:\/\/solidt.eu\/site\/powershell-recursive-rename-files-javascript-to-typescript\/","title":{"rendered":"Powershell: Recursive Rename files (Javascript to Typescript)"},"content":{"rendered":"\n<div style=\"height: 250px; position:relative; margin-bottom: 50px;\" class=\"wp-block-simple-code-block-ace\"><pre class=\"wp-block-simple-code-block-ace\" style=\"position:absolute;top:0;right:0;bottom:0;left:0\" data-mode=\"powershell\" data-theme=\"monokai\" data-fontsize=\"14\" data-lines=\"Infinity\" data-showlines=\"true\" data-copy=\"false\">$files = Get-ChildItem -File -Recurse -Filter *.js \nforeach($file in $files)\n{\n\t$name = $file.Name -Replace '\\.js$','.ts'\n\tRename-Item -Path $file -NewName $name\n}\t<\/pre><\/div>\n\n\n\n<p>A first stept to prepare some files:<\/p>\n\n\n\n<div style=\"height: 250px; position:relative; margin-bottom: 50px;\" class=\"wp-block-simple-code-block-ace\"><pre class=\"wp-block-simple-code-block-ace\" style=\"position:absolute;top:0;right:0;bottom:0;left:0\" data-mode=\"sh\" data-theme=\"monokai\" data-fontsize=\"14\" data-lines=\"Infinity\" data-showlines=\"true\" data-copy=\"false\">lebab --replace .\/**\/*.js --transform commonjs\n\n\n\n# some notes:\n\n# import globals\nexport const angular = (window as any).angular;\nconst moment = (window as any).moment;\n\n# Search\/Replace *.ts in vscode:\n^require\\('(.*)'\\);\nimport \"$1\";\n\n\n# Search\/Replace *.ts in vscode:\n\\bwindow\\.\n(window as any).\n\nimport dateHelper from \"..\/..\/..\/helpers\/dateHelper\";\n=>\nimport * as dateHelper from \"..\/..\/..\/helpers\/dateHelper\";\n<\/pre><\/div>\n\n\n\n<p>For more see:  <a href=\"https:\/\/solidt.eu\/site\/lebab-modernizing-javascript\/\">https:\/\/solidt.eu\/site\/lebab-modernizing-javascript\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A first stept to prepare some files: For more see: https:\/\/solidt.eu\/site\/lebab-modernizing-javascript\/<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[5,4,1],"tags":[],"class_list":["post-6321","post","type-post","status-publish","format-standard","hentry","category-javascript","category-programming","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/6321","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/comments?post=6321"}],"version-history":[{"count":2,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/6321\/revisions"}],"predecessor-version":[{"id":6323,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/6321\/revisions\/6323"}],"wp:attachment":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/media?parent=6321"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/categories?post=6321"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/tags?post=6321"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}