header1   header
header
header : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
IMPORTANT: PowerShellCommunity.org is moving! - Wednesday, August 15, 2012

PowerShellCommunity.org is moving!  This community software, and the hardware that it sits on, are no longer serving the purposes of this community.  As a result, we have decided to move this community to a new home at PowerShell.org.  PowerShell.org is already up and running with the new community software and in its new location, so please post any new questions that you have on the forums over there instead of posting them on this site.  We've already started getting some great questions from members of the community over there so please, come on over and join us!

While we are going through this transition, this site will remain up for the short term.  New posts may no longer be created on these forums, however replies to existing posts are allowed so that users who posted questions don't have to re-post the same question on the new site.

[UPDATE 28/02/2013] New user registration has been disabled and forums have now been switched to read-only, including for existing posts since all threads that were started should now be completed. If you have a question about content on this site or about PowerShell in general, head over to PowerShell.org and ask it there where there are people actively using the site and answering questions.

If you have any questions, please let us know on the PowerShell.org site.

Thank you,

Kirk "Poshoholic" Munro

 
Moving folders
Last Post 25 Apr 2012 01:30 PM by James L.. 2 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages Resolved
James L.User is Offline
New Member
New Member
Posts:2
Avatar

--
24 Apr 2012 11:07 AM
    I have a group of user folders (they are named with the username). I would like to pull out one particular folder from each of the user folders and move it to a separate folder. The folder I'm pulling out has the same name in each user folder, but I need to keep it associated with the particular user. Can someone help me with a script that searches the user folders, and when the particular folder is found pulls it out and places it in a new folder but with the same username? Thanks.

    James
    EBGreenUser is Offline
    Veteran Member
    Veteran Member
    Posts:1276
    Avatar

    --
    24 Apr 2012 03:04 PM
    So, here is one way to do it at the command line:

    ls | ?{$_.PsIsContainer} | %{$user = $_.name; Copy "$($_.Fullname)\foo.txt" ".\bucket\foo_$user.txt" -ea 0}

    I wrote it to be run in the parent folder of all the user folders. You can tweak it to grab the file that you want and to put the files wherever you want.
    "Look Ma...no strings!"
    James L.User is Offline
    New Member
    New Member
    Posts:2
    Avatar

    --
    25 Apr 2012 01:30 PM
    Thanks. That really helped a lot.
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Many thanks to our original sponsors: Quest Software • SAPIEN Technologies • Compellent • Microsoft footer
    footer   footer