I want to count the elements in the pipeline and also process them
The following script works, but only because I save the pipeline contents in a variable. I would like to not have to save it - see below. The commented section is my most recent failure. (And BTW I know the script has nothing to do with ZIP: that's
the next step.
function ZipUpModified {
param ([string] $from, [string]$to, [datetime]$cutOff)
try
Write-Host ("Copying {0} modified on or after {1} to {2} in execution at {3}" -f $from, $cutOff.toString(), $to, $(Get-Date))
if (-not (Test-Path -Path $from)) {Throw "Source folder $from does not exist"}
if (Test-Path -Path $to) {Throw "Target folder $to already exists"}
# I would like to substitute the next 5 lines for the following 4; but I cannot seem to get the pipeline to reach the Copy_Item
# $fileCount=0
# Get-ChildItem $from -Recurse |
# Where-Object {(New-TimeSpan -Start $_.LastWriteTime -End $cutoff).TotalHours -le 0} |
# ForEach-Object {Copy-Item -Destination {Join-Path $to $_.FullName.Substring($from.length)}; $fileCount++; }
# Write-Host ("Copied {0} files/folders successfully at {1}" -f $fileCount, $(Get-Date))
$filelist=Get-ChildItem $from -Recurse |
Where-Object {(New-TimeSpan -Start $_.LastWriteTime -End $cutoff).TotalHours -le 0}
$filelist | Copy-Item -Destination {Join-Path $to $_.FullName.Substring($from.length)}
Write-Host ("Copied {0} files/folders successfully at {1}" -f $filelist.count, $(Get-Date))
catch
Write-Host $($_.Exception.ToString() -replace ".*: ")
Write-Host "so we are stopping..."
finally
$IgnoreThis = Read-Host "hit OK or Enter"
### Main
$cutOff= (Read-Host 'Enter date of most recent backup (mm/dd/yyyy):') | Get-Date
ZipUpModified "C:\Users\Jonathan\Desktop\Test_BU\SRC" "C:\Users\Jonathan\Desktop\Test_BU\TGT" $cutOff
## two more calls to ZipUpModified
Guys - Thanks for the quick response
Bill - I think you are recommending the approach I had in the submitted code.
David - the whole point is that I want to use the pipeline, not the Path argument, and I had no luck with your suggestion, which I took as:
Get-ChildItem $from -Recurse |
Where-Object {(New-TimeSpan -Start $_.LastWriteTime -End $cutoff).TotalHours -le 0} |
ForEach-Object {Copy-Item -Path $_ -Destination {Join-Path $to $_.FullName.Substring($from.length)}; $fileCount++}
However, all this did make me go read more documentation, and there is a -PassThru argument to Copy-Item which creates pipeline output after the copy. Specifically:
$fileCount=0
Get-ChildItem $from -Recurse |
Where-Object {(New-TimeSpan -Start $_.LastWriteTime -End $cutoff).TotalHours -le 0} |
Copy-Item -Destination {Join-Path $to $_.FullName.Substring($from.length)} -PassThru |
ForEach-Object {$fileCount++}
Write-Host ("Copied {0} files/folders successfully at {1}" -f $fileCount, $(Get-Date))
Thanks again
JonW
JonW
Similar Messages
-
Want to count the number of rows of analysis item in WAD Template
HI all,
Detail Description:
In my WAD report, i have a Export to Excel Option. But I want when I click on this button, one pop up will come only if no of rows of the Analysis Item is Greater than 10,000 ask for Do you want to proceed or not.
Means 1st i want to count the no of rows in the Analysis Item, after that it will check, if the no of rows is greater that 10,000. then the pop up will come.
Question:
Does anyone know, "how to count the no of rows of the analysis Item ?" . It will be better if you know you to implement this with the help of java script.
Means there must be some varible, which counts the no of rows. If you know then please help meHi,
Please find the below link which helps you to get solution of your question.
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d0bbb20f-2d7e-2e10-258f-8655daa41fab?QuickLink=index&overridelayout=true
It is mainly used to automate queries, web templates, and reports in different output formats like PDF, Excel,
XML, XHTML, and HTML
How to see WAD reports on browser:
The BEx Web Application Designer is a desktop application for creating Web applications with BW-specific contents. Using the BEx Web Application Designer, you can create an HTML page that contains contents such as various tables, charts or maps. This HTML page (Web application) provides the basis for not only Web applications with complex interaction, but also for Web cockpits and iViews.
http://help.sap.com/saphelp_nw04/helpdata/en/1a/456a3badc1b315e10000000a114084/content.htm
Web Application Designer for Beginners
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/749a4622-0a01-0010-36bf-b6b30a2a3a22
Web Application Solutions: A Designer's Guide
http://www.lukew.com/resources/webapplicationsolutions.pdf
http://sap.ittoolbox.com/groups/technical-functional/sap-solution-manager/bw-web-application-designer-1955944
Feautures of WAD in 7.0
http://help.sap.com/saphelp_nw70/helpdata/en/88/4d354277dcb26be10000000a155106/frameset.htm
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/5c46376d-0601-0010-83bf-c4f5f140e3d6
Regards
Sudheer -
I have ordered to buy the program Photoshop Elements mistake, and I want to cancel the request and re-ordering program Lightroom5 please!
Please see Return, cancel, or exchange an Adobe order -
http://helpx.adobe.com/x-productkb/policy-pricing/return-cancel-or-change-order.html
Cancel your membership or subscription | Creative Cloud
https://helpx.adobe.com/x-productkb/policy-pricing/cancel-membership-subscription.html -
I just want to launch the program and retouch a photo.[was:lost]
i just want to launch the program and retouch a photo. why am i so lost?
Exactly my point. With all the "training" and "introduction" and promotional
hoopla on the CC platform, I couldn't even find a way to LAUNCH photoshop.
I eventually simply downloaded Photoshop Elements. Problem solved.
Your Partner in Development
Robert Ott PMP
Earth Energy Exchange, Ltd.
631-371-6842 -
i have a mac mini mid 2011, this device have; 2,3GHz and 2 Gb Memmory.I want to upgrade the memory and i need the list of supported memory modules. i am from turkey.
Welcome to Apple Support Communities
The Mid 2011 Mac mini supports 8 GB of memory officially, but you can install up to 16 GB of RAM, so you can use 2, 4 and 8 GB modules. You can buy more RAM from OWC or Crucial.
If you are looking for memory at a local shop, make sure you buy 1333 MHz DDR3 memory. See > http://support.apple.com/kb/HT4432?viewlocale=en_US&locale=en_US -
I want to change the sharing and permissions of a large number of photos. How can I do this in bulk rather than one at a time?
Does this involve iPhoto in some way?
-
how can I restore my back up files from my laptop? i want to see the dates and time that I backed up my files. is it posssible?
What backed up files?
Available backups for an iOS device can be found in Edit > Preferences > Devices. -
I do not know the password for my icloud account on my iphone 5S, I also want to elete the account and set a new one?
Hi Tania1894,
If you do not know your iCloud password and did not receive your reset email, I would suggest that you troubleshoot using the steps in this article -
If you didn't receive your Apple ID verification or reset email
Thanks for using Apple Support Communities.
Best,
Brett L -
My iPod touch shows up as a apple iPod camera but if i dont want to download the pics and press cancel it all dissappears. my ipod has been lost for 3 months and has not got the latest upgrade.
Try:
iOS: Device not recognized in iTunes for Windows
or
iOS: Device not recognized in iTunes for Mac OS X
Otherwise wee need more informatin. -
I want to remove the header and footer when printing from my mac, I can do this in the Page Setup on my PC but not on the Mac. I can do it each time I print but then it resets. How do I make a universal change?
== This happened ==
Every time Firefox openedGo to the "File" menu, then "Print." The window that appears will have three drop-down menus at the top.
The first is labeled "Printer",
The second is "Presets".
The third is unlabeled but has "Copies & Pages" selected by default.
Click on that third menu and select "Firefox" near the bottom of the list. -
I bought yesterday my macbook pro and I want to join the FaceTime and I just can´t... It said that is not working and try it later... but since yesterday said that .. What should I do?
Here's a previous discussions that seems to have solved a similar issue in the past:
https://discussions.apple.com/message/12209861#12209861 -
I set up Firefox sync from my old computer. This has had its hard drive replaced and been sold. I now want to retrieve the information and get my bookmarks on my new computer. I can't see any way to do this!
Help pleaseTo build on the second option provided by The Edmeister make sure that you have your Sync Key, if this is not the case Firefox Sync will not help you (data is encrypted with that Key).
Finally, if the last sync happened long time ago, it may be the case that your data is not on the servers anymore. Firefox Syn wasn't designed as a back up service. -
Hey, I'm having trouble launching Itunes, I wanted to updated but it didn't open so I wento to this page and downloaded the latest version, and now Itunes doesen't want to launch again. Help me please and also I want to know if my music will be erased?!?! Sorry for my ignorance but i'm not good at this kind of stuff. I will aprecciate a lot if you could help me please!!!! :c
Hi cheperrumps,
Welcome to the Support Communities!
Uninstalling or reinstalling the iTunes application won't affect your music (data) -- but it's always a good idea to have a backup!
The information below will show you how to do that and to troubleshoot your issue with iTunes:
iTunes: Back up your iTunes library by copying to an external hard drive
http://support.apple.com/kb/ht1751
iTunes for Windows Vista or Windows 7: Troubleshooting unexpected quits, freezes, or launch issues
http://support.apple.com/kb/ts1717
Cheers,
- Judy -
I created an iDVD through iMovie on one computer in my home and want to edit the slideshow and delete some videos on the iDVD. However, I want to work on my own iMac. Is there a way to "share" the original project through the drop box on my computer?
Sir Churchill, I tried deleting one of the playlists from my computer (Playlist 130). The next day I checked my wife's computer and noticed that Playlist 130 was now missing from her computer as well. Is there a way that I can delete a playlist from my computer without it disappearing from hers as well?
-
I want to change the size and color of text in call out boxes and text boxes. How can I do this? Jack
Highlite the text inside the text box and then press Ctrl+E.
Maybe you are looking for
-
How do I convert more than the menus from 16:9 to 4:3?
I'm trying to make two versions of a wedding movie, one for widescreen users and one for oldsters with pre-HD television sets in the 4:3 aspect ratio. After successfully burning many copies at the 16:9 ratio, iDVD allowed me to convert my theme to 4:
-
Does anyone know where toeither get refunded or am I out this MOney?
-
XI Adapter not visible in CC Monitoring
Hi all, I have configured Receiver XI Adapter for a server ABAP proxy. When I executed the scenario, I can see the successfull message in the SXI_MONITOR. But in the receiver side its not get reflected. So I went to the "Communication Channel Monitor
-
PO HEADER LEVEL의 TOTAL AMOUNT 계산 LOGIC
제품 : MFG_PO 작성날짜 : 2004-10-13 PO HEADER LEVEL의 TOTAL AMOUNT 계산 LOGIC ========================================== PURPOSE Purchase Order 화면의 Header level에 보여주는 Total Amount 계산 logic을 알아본다. Explanation Purchase Order 화면에서 PO를 입력하거나 조회해 본 사람은 PO Header l
-
Accordion panel spry not working...
Can someone please look at this site and see what I am doing wrong? My accordion is not working on the "heaven" page, but does work on the "about" page. ??? This link is the problem page. This link, with the same accordion (on the same site) works fi