{"id":5192,"date":"2024-10-24T08:17:25","date_gmt":"2024-10-24T15:17:25","guid":{"rendered":"https:\/\/SUMMALAI.COM\/?p=5192"},"modified":"2024-10-24T08:26:15","modified_gmt":"2024-10-24T15:26:15","slug":"how-to-create-folders-from-a-csv-file-by-using-powershell","status":"publish","type":"post","link":"https:\/\/SUMMALAI.COM\/?p=5192","title":{"rendered":"How to Create Folders from a CSV file by Using PowerShell"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"5192\" class=\"elementor elementor-5192\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-015cde8 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"015cde8\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-065cdbb\" data-id=\"065cdbb\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-fb349c8 elementor-widget elementor-widget-text-editor\" data-id=\"fb349c8\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Here is a sample csv file with a title called &#8220;Organizations&#8221;.&nbsp;<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-e593714 elementor-widget elementor-widget-image\" data-id=\"e593714\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img fetchpriority=\"high\" decoding=\"async\" width=\"304\" height=\"546\" src=\"https:\/\/SUMMALAI.COM\/wp-content\/uploads\/2024\/10\/Capture.png\" class=\"attachment-large size-large wp-image-5193\" alt=\"sample csv file\" srcset=\"https:\/\/SUMMALAI.COM\/wp-content\/uploads\/2024\/10\/Capture.png 304w, https:\/\/SUMMALAI.COM\/wp-content\/uploads\/2024\/10\/Capture-167x300.png 167w\" sizes=\"(max-width: 304px) 100vw, 304px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-8d1f5b3 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"8d1f5b3\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-98f832d\" data-id=\"98f832d\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap\">\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-55bcea71 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"55bcea71\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-324669f0\" data-id=\"324669f0\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-46f51414 elementor-widget elementor-widget-text-editor\" data-id=\"46f51414\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><\/p>\n<h5 class=\"wp-block-heading\">Below, please see the scripts<\/h5>\n<p><\/p>\n<p>#Crated by Summa, 2024-10-23<\/p>\n<p>\u00a0<\/p>\n<p>$file= &#8220;C:\\Temp\\folders.csv&#8221;<\/p>\n<p><span style=\"font-size: 13px; color: var( --e-global-color-text );\">if (Test-Path $file) {<\/span><\/p>\n<p><span style=\"font-size: 13px; color: var( --e-global-color-text );\">\u00a0 \u00a0 $item=Get-Item $file<\/span><\/p>\n<p><span style=\"font-size: 13px; color: var( --e-global-color-text );\">\u00a0 \u00a0 Write-Output &#8220;The csv file exists. Details:&#8221;<\/span><\/p>\n<p><span style=\"font-size: 13px; color: var( --e-global-color-text );\">\u00a0 \u00a0 $item<\/span><\/p>\n<p><span style=\"font-size: 13px; color: var( --e-global-color-text );\">} else {<\/span><\/p>\n<p><span style=\"font-size: 13px; color: var( --e-global-color-text );\">\u00a0 \u00a0 Write-Output &#8220;The csv file does not exist.&#8221;<\/span><\/p>\n<p><span style=\"font-size: 13px; color: var( --e-global-color-text );\">}<\/span><\/p>\n<p><span style=\"font-size: 13px; color: var( --e-global-color-text );\">$folderlist = Import-Csv $file<\/span><\/p>\n<p>$rootpath = &#8220;C:\\Sample Folder\\&#8221;<\/p>\n<p>foreach ($folder in $folderlist){<\/p>\n<p>\u00a0 \u00a0 $path = join-path -path $rootpath -childpath $folder.Organizations;<\/p>\n<p>\u00a0 \u00a0 if (-not (Test-Path -Path $path)) {<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 # Create the folder<\/p>\n<p>\u00a0 \u00a0 new-item -type directory -path $path;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Write-Output &#8220;Created folder: $path&#8221;<\/p>\n<p>\u00a0 \u00a0 } else {<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 Write-Output &#8220;Folder already exists: $path&#8221;<\/p>\n<p>\u00a0 \u00a0 }\u00a0<\/p>\n<p>}\u00a0<\/p>\n<p><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Here is a sample csv file with a title called &#8220;Organizations&#8221;.&nbsp; Below, please see the scripts #Crated by Summa, 2024-10-23 \u00a0 $file= &#8220;C:Tempfolders.csv&#8221; if (Test-Path $file) { \u00a0 \u00a0 $item=Get-Item $file \u00a0 \u00a0 Write-Output &#8220;The csv file exists. Details:&#8221; \u00a0 \u00a0 $item } else { \u00a0 \u00a0 Write-Output &#8220;The csv file does not exist.&#8221; } <a class=\"read-more\" href=\"https:\/\/SUMMALAI.COM\/?p=5192\">Read More<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[10,1224],"tags":[1824,1825],"class_list":["post-5192","post","type-post","status-publish","format-standard","hentry","category-microsoft","category-powershell","tag-create-folders-from-a-csv-file","tag-create-folders-from-a-csv-file-powershell"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/5192","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5192"}],"version-history":[{"count":6,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/5192\/revisions"}],"predecessor-version":[{"id":5199,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/5192\/revisions\/5199"}],"wp:attachment":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5192"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5192"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5192"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}