![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
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.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | copying files referenced in an array...help? How would i create an array with a list of files in it, then have those files copied to a specific location? would you use a ForEach statement? Also, how would i set it up so i wouldnt have to state the full path for each file? I'd like to be able to do $arrayname= file1, file2 instead of $arrayname= C:\users\jason\desktop\files\file1...etc. |
My System Specs![]() |
| | #2 (permalink) | ||||||||||||
| Guest | Re: copying files referenced in an array...help? If all files share a common *root* directory (user desktop) then you can specify only the relative part, otherwise use full paths: $files = "file1.txt","file2.txt","file3.txt" $files | copy-item -path {"$env:userprofile\desktop\$_"} -dest c:\temp ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com
| ||||||||||||
My System Specs![]() | |||||||||||||
| | #3 (permalink) | ||||||||||||||||||||||||
| Guest | Re: copying files referenced in an array...help? btw... if you use full file paths then no piping is required since -path is a string[] array: $files = "C:\users\jason\desktop\files\file1.txt","C:\users\jason\desktop\files\file2.txt" copy-item -path $files -dest c:\temp ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com
| ||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||
| | #4 (permalink) | ||||||||||||||||||||||||
| Guest | Re: copying files referenced in an array...help? Can you explain the second line? especially the $_ "Shay Levi" wrote:
| ||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||
| | #5 (permalink) | ||||||||||||||||||||||||||||||||||||
| Guest | Re: copying files referenced in an array...help? Copy-Item's -Path parameter allows strings to be piped into it which means that scriptblock parameters apply. This way you can manipulate the piped string via $_. ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com
| ||||||||||||||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||||||||||||||
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Copying an array and weird things about updating arrays... | bruce1313 | PowerShell | 7 | 08-03-2008 10:57 PM |
| Newbie question - Copying files listed in an array | greatbarrier86 | PowerShell | 5 | 02-20-2008 04:03 PM |
| Copying files to Program Files directory | Parrot | Vista file management | 13 | 08-23-2007 01:14 AM |
| how to assign values to array and how to create array via variable | Frank | PowerShell | 1 | 03-13-2007 05:18 PM |
| Copying what files? | Navdeep Singh | Vista installation & setup | 2 | 06-09-2006 12:34 PM |