Go Back   CORTEX Forums > Local Happenings > CORTEX Blogs > Random Procrastination
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read

PowerShell One Liner: Duplicating a folder structure in a Sharepoint document library

This is a discussion on PowerShell One Liner: Duplicating a folder structure in a Sharepoint document library within the Random Procrastination forums, part of the CORTEX Blogs category; I was asked by someone at work the other day, if it was possible in Sharepoint to create a set of top level folders in one document library based on ...


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 24th May 2010, 11:28 PM   #1
Senior Member
 
Join Date: Jun 2009
Posts: 62
Darren Gosbell is on a distinguished road
Thumbs up PowerShell One Liner: Duplicating a folder structure in a Sharepoint document library

I was asked by someone at work the other day, if it was possible in Sharepoint to create a set of top level folders in one document library based on the set of folders in another library. One document library has a set of top level folders that is basically a client list and we needed to create the same top level folders in another library.

I knew that it was possible to open a Sharepoint document library in explorer using a UNC style path and that you could map a drive using a technique like this one: http://www.endusersharepoint.com/200...-mapped-drive/. But while explorer would let us copy the folders, it would also take all of the folder contents too, which was not what we wanted.

So I figured that some sort of PowerShell script was probably the way to go and it turned out to be even easier than I thought. The following script did it in one line, so I thought I would post it here in my "online memory". :)

dir "\\sharepoint\client documents" | where {$_.PSIsContainer} | % {mkdir "\\sharepoint\admin documents\$($_.Name)"}

I use "dir" to get a listing from the source folder, pipe it through "where" to get only objects that are folders and then do a foreach (using the % alias) and call "mkdir".






Get More from the original blog...
Darren Gosbell is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiTweet this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Document controller admin 2010 Job Archive 0 8th May 2010 04:32 PM
Documentation Manager - Online library administrator - Leading IT admin 2010 Job Archive 0 8th April 2010 04:25 AM
Pricing Partners Incorporates the Portfolio Function into Price-It Library Latest News Headlines 2009 Q4 News Headlines 0 24th December 2009 07:49 AM
PowerShell: List all the senders from an Outlook folder Darren Gosbell Random Procrastination 0 23rd June 2009 08:30 PM
SSAS: Powershell to replace a group member in a role Darren Gosbell Random Procrastination 0 23rd June 2009 08:30 PM


All times are GMT +11. The time now is 05:14 AM.

© The Business Intelligence Group

Search Engine Optimization by vBSEO