one zip file, but certain files to different locations

This topic contains 8 replies, has 2 voices, and was last updated by Profile photo of Graham Beer Graham Beer 11 months, 1 week ago.

  • Author
    Posts
  • #33535
    Profile photo of Graham Beer
    Graham Beer
    Participant

    I'm trying to work out how i can achieve this.

    I have one zip file that i want extract and 6 files go in one folder, a different 6 to another.

    The files are the same name but change slightly per month as part of a release.

    I'll be using the below to unzip the files :

    Add-Type -assembly "system.io.compression.filesystem"
    
    [io.compression.zipfile]::ExtractToDirectory($Location, $destination)
    

    But how can i move certain files to different locations ? Could i create an XML file ? Or create two hash tables and copy them to required locations ?

    XML would be good, but not sure how to go about this.

  • #33561
    Profile photo of Don Jones
    Don Jones
    Keymaster

    In a single unzip operation, you can't send the files to different destinations. You have to unzip them first, and then move them to where you want them.

  • #33604
    Profile photo of Graham Beer
    Graham Beer
    Participant

    OK, thanks Don.
    Just for my own reference, could i set directory paths through XML and use powershell to look at the XML and do the copy ? I'm happy i could do this through splatting but interested by the learning the XML way.

  • #33631
    Profile photo of Don Jones
    Don Jones
    Keymaster

    I'm not sure what "the XML way" even is :). I'm not aware of a command that can take an XML file as input to a file copy operation.

  • #33640
    Profile photo of Graham Beer
    Graham Beer
    Participant

    OK Don. My Mistake, thought i could do this sort of thing with XML.
    Thanks for your time.

  • #33643
    Profile photo of Don Jones
    Don Jones
    Keymaster

    Is there something I'm missing? I mean, was there something somewhere you read along those lines? Just because I'm not aware doesn't mean it doesn't exist, so if you've seen something I'd love to have a look!

  • #33645
    Profile photo of Graham Beer
    Graham Beer
    Participant

    Sorry Don, no i've not seen anything. Just curious to know if it could be done. Thought it could be quite cool ! 🙂

  • #33646
    Profile photo of Don Jones
    Don Jones
    Keymaster

    Time for you to write a command that does :).

  • #33648
    Profile photo of Graham Beer
    Graham Beer
    Participant

    Ha ha, Sounds like a challenge, i'll crack on !

You must be logged in to reply to this topic.