Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Chronicles of a Script

Closed Thread
 
Thread Tools Display Modes
Old 12-31-2006   #1 (permalink)
$hay
Guest


 

Chronicles of a Script

Hey all

New post about generating directory structrues
at http://scriptolog.blogspot.com

$hay



Old 12-31-2006   #2 (permalink)
Jeffrey Snover [MSFT]
Guest


 

Re: Chronicles of a Script

Good stuff but this should be easier in PowerShell. Maybe you should
request the /T functionaility be available in copy-item.
--
Jeffrey Snover [MSFT]
Windows PowerShell Architect
Microsoft Corporation
This posting is provided "AS IS" with no warranties, no confers rights.


Old 12-31-2006   #3 (permalink)
Keith Hill [MVP]
Guest


 

Re: Chronicles of a Script

"Jeffrey Snover [MSFT]" <jsnover@ntdev.microsoft.com> wrote in message
news:A73A47F0-2467-445C-B05C-A8F6B4C9A4C9@microsoft.com...
> Good stuff but this should be easier in PowerShell. Maybe you should
> request the /T functionaility be available in copy-item.


Agreed. The -recurse feature on copy-item works good if you want to copy a
"dir" and retain the dir structure. But if you want to copy the "contents"
of a dir to another existing dir and retain the directory structure, it
doesn't work. This definitely should be easy in PoSH.

--
Keith


Old 12-31-2006   #4 (permalink)
$hay
Guest


 

Re: Chronicles of a Script

10x guys, i hope its not a case of misunderstanding. The whole thing is
about duplicating
source directory tree to another location WITHOUT the files. (so if it is,
plz specify it
in your replies, so ill can clarify myself and correct the text :-).

Now, correct me if im wrong :

- I have to use a cmdlet (either copy-item or new-item).
- In both cmdlets the -recurse will be on
- Distinguish between file items or directory have to be checked.

How can i make it easier/shorter?

$hay





"Keith Hill [MVP]" <r_keith_hill@mailhot.moc.nospam> wrote in message
news:eb$7IpQLHHA.4992@TK2MSFTNGP04.phx.gbl...
> "Jeffrey Snover [MSFT]" <jsnover@ntdev.microsoft.com> wrote in message
> news:A73A47F0-2467-445C-B05C-A8F6B4C9A4C9@microsoft.com...
>> Good stuff but this should be easier in PowerShell. Maybe you should
>> request the /T functionaility be available in copy-item.

>
> Agreed. The -recurse feature on copy-item works good if you want to copy
> a "dir" and retain the dir structure. But if you want to copy the
> "contents" of a dir to another existing dir and retain the directory
> structure, it doesn't work. This definitely should be easy in PoSH.
>
> --
> Keith
>



Old 12-31-2006   #5 (permalink)
Keith Hill [MVP]
Guest


 

Re: Chronicles of a Script

"$hay" <no@addre.ss> wrote in message news:OW8ujNRLHHA.420@TK2MSFTNGP06.phx.gbl...
> 10x guys, i hope its not a case of misunderstanding. The whole thing is
> about duplicating
> source directory tree to another location WITHOUT the files. (so if it is,
> plz specify it
> in your replies, so ill can clarify myself and correct the text :-).
>
> Now, correct me if im wrong :
>
> - I have to use a cmdlet (either copy-item or new-item).
> - In both cmdlets the -recurse will be on
> - Distinguish between file items or directory have to be checked.
>
> How can i make it easier/shorter?
>
> $hay


To be clear for folks reading this, copying one directory to another existing or non-existing dir is easy:

Copy-Item SrcDir ExistingDestDir -rec

this will copy the SrcDir and all its contents under ExistingDestDir

Copy-Item SrcDir NonExistingDestDir -rec

this will copy SrcDir and all its contents to a newly created dest dir with the same leaf dir name as the SrcDir.

Even copying the contents of a dir (recursively) is easy e.g.:

Copy-Item SrcDir\* ExistingDestDir -rec

What is proving painful is copying just the contents of the src dir while filtering what is copied:

Copy-Item SrcDir\* ExistingDestDir -rec -filter *.txt

The above doesn't work, it copies nothing to the dest dir.

However copying the SrcDir itself does work with -filter:

Copy-Item SrcDir Existing(OrNonExisting)DestDir -rec -filter *.txt

So if the dest dir doesn't exist, you king of get the equivalent of copying the contents with filtering enabled. You would then need to move that new directories contents to the desired location e.g.:

$tempDestDir = $env:Temp\<someTempDirName>
md $tempDestDir
Copy-Item SrcDir $tempDestDir -rec -filter *.txt
Move-Item $tempDestDir \* $destDir
Remove-Item $tempDestDir -rec -force

So yeah this one use case is definitely harder than it should be in PoSH.

--
Keith




Old 01-01-2007   #6 (permalink)
Keith Hill [MVP]
Guest


 

Re: Chronicles of a Script

I submitted this a bug:

https://connect.microsoft.com/feedba...9114&SiteID=99

Vote on it if you can.

--
Keith
Old 01-01-2007   #7 (permalink)
$hay
Guest


 

Re: Chronicles of a Script

10x Keith
"Keith Hill [MVP]" <r_keith_hill@mailhot.moc.nospam> wrote in message news:u1adkhRLHHA.1008@TK2MSFTNGP06.phx.gbl...
"$hay" <no@addre.ss> wrote in message news:OW8ujNRLHHA.420@TK2MSFTNGP06.phx.gbl...
> 10x guys, i hope its not a case of misunderstanding. The whole thing is
> about duplicating
> source directory tree to another location WITHOUT the files. (so if it is,
> plz specify it
> in your replies, so ill can clarify myself and correct the text :-).
>
> Now, correct me if im wrong :
>
> - I have to use a cmdlet (either copy-item or new-item).
> - In both cmdlets the -recurse will be on
> - Distinguish between file items or directory have to be checked.
>
> How can i make it easier/shorter?
>
> $hay


To be clear for folks reading this, copying one directory to another existing or non-existing dir is easy:

Copy-Item SrcDir ExistingDestDir -rec

this will copy the SrcDir and all its contents under ExistingDestDir

Copy-Item SrcDir NonExistingDestDir -rec

this will copy SrcDir and all its contents to a newly created dest dir with the same leaf dir name as the SrcDir.

Even copying the contents of a dir (recursively) is easy e.g.:

Copy-Item SrcDir\* ExistingDestDir -rec

What is proving painful is copying just the contents of the src dir while filtering what is copied:

Copy-Item SrcDir\* ExistingDestDir -rec -filter *.txt

The above doesn't work, it copies nothing to the dest dir.

However copying the SrcDir itself does work with -filter:

Copy-Item SrcDir Existing(OrNonExisting)DestDir -rec -filter *.txt

So if the dest dir doesn't exist, you king of get the equivalent of copying the contents with filtering enabled. You would then need to move that new directories contents to the desired location e.g.:

$tempDestDir = $env:Temp\<someTempDirName>
md $tempDestDir
Copy-Item SrcDir $tempDestDir -rec -filter *.txt
Move-Item $tempDestDir \* $destDir
Remove-Item $tempDestDir -rec -force

So yeah this one use case is definitely harder than it should be in PoSH.

--
Keith




Old 01-01-2007   #8 (permalink)
$hay
Guest


 

Re: Chronicles of a Script

just visited the link.
FYI, after logging with my passport i get
an error from microsoft: page noe found.

hope this is not my inernet connection :-)
"Keith Hill [MVP]" <r_keith_hill@mailhot.moc.nospam> wrote in message news:uvcEiAXLHHA.4916@TK2MSFTNGP06.phx.gbl...
I submitted this a bug:

https://connect.microsoft.com/feedba...9114&SiteID=99

Vote on it if you can.

--
Keith
Old 01-01-2007   #9 (permalink)
Keith Hill [MVP]
Guest


 

Re: Chronicles of a Script

I'm not sure that the PowerShell project on the connect site is open to join anymore. Did you try to join the project? If it is true that it isn't open to join anymore then this leaves new users with no place to submit feedback.

--
Keith
"$hay" <no@addre.ss> wrote in message news:eZ57mFYLHHA.420@TK2MSFTNGP06.phx.gbl...
just visited the link.
FYI, after logging with my passport i get
an error from microsoft: page noe found.

hope this is not my inernet connection :-)
"Keith Hill [MVP]" <r_keith_hill@mailhot.moc.nospam> wrote in message news:uvcEiAXLHHA.4916@TK2MSFTNGP06.phx.gbl...
I submitted this a bug:

https://connect.microsoft.com/feedba...9114&SiteID=99

Vote on it if you can.

--
Keith
Old 01-01-2007   #10 (permalink)
$hay
Guest


 

Re: Chronicles of a Script

i did join some other projects earlier, but i cant find any reference to PowerShell's.

$hay
"Keith Hill [MVP]" <r_keith_hill@mailhot.moc.nospam> wrote in message news:u5g2ULYLHHA.2140@TK2MSFTNGP03.phx.gbl...
I'm not sure that the PowerShell project on the connect site is open to join anymore. Did you try to join the project? If it is true that it isn't open to join anymore then this leaves new users with no place to submit feedback.

--
Keith
"$hay" <no@addre.ss> wrote in message news:eZ57mFYLHHA.420@TK2MSFTNGP06.phx.gbl...
just visited the link.
FYI, after logging with my passport i get
an error from microsoft: page noe found.

hope this is not my inernet connection :-)
"Keith Hill [MVP]" <r_keith_hill@mailhot.moc.nospam> wrote in message news:uvcEiAXLHHA.4916@TK2MSFTNGP06.phx.gbl...
I submitted this a bug:

https://connect.microsoft.com/feedba...9114&SiteID=99

Vote on it if you can.

--
Keith
Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Myst Uru Complete Chronicles, HELP PLEASE! Dustmover Gaming 7 1 Week Ago 09:03 PM
Include another script, keep variables in included script? pschmidt PowerShell 32 2 Weeks Ago 01:48 PM
Uru complete chronicles phypps Vista Games 0 03-13-2008 10:33 AM
Script file has 'OS Handle' error when run from script Jay PowerShell 1 09-18-2007 07:06 PM
Can you drag-n-drop a file on top of a PS script to run the script? Jen Taylor PowerShell 6 04-06-2007 09:02 AM








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50