asked on
Change PowerShell script to eliminate 4 second pausing if file(s) not present in source
I would like to change this script so that only if the file exists, it performs the copy and then pauses for 4 seconds.
If the *.csv file(s) do not exist, then it should move on to the .bat file to perform the next function.
Thanks in advance for your help.
pushd "E:\Users\Users1\Inbound\"
if exist *.csv copy /b E:\Users\Users1\InboundCopy\*.csv amalgamated.csv
popd
ping -n 4 -w 1000 127.0.0.1 > nul
....
pushd "E:\Users\Users1\Inbound\"
if not exist *.csv goto End_Copy
copy /b E:\Users\Users1\InboundCopy\*.csv amalgamated.csv
ping -n 4 -w 1000 127.0.0.1 > nul
:End_Copy
popd
Though again, I don't see the need for the pause (unless you want to have a bit of time to see the results).The copy will be done when the call to copy returns, this is nothing that continues in the background.
ASKER
Thakns oBdA,
I tried using the same type of script that was presented yesterday with *.csv files but it did not copy if I remember well.
Thanks again.
you "pushd" to "E:\Users\Users1\Inbound",
If they are supposed to be the same, you might want to change that to something like
set source=E:\Users\Users1\Inbound
if not exist "%source%\*.csv" goto End_Copy
copy /b "%source%\*.csv" "%source%\amalgamated.csv"
ping -n 4 -w 1000 127.0.0.1 > nul
:End_Copy
Edit: Fixed target path
ASKER
Thanks oBDA,
They should be 2 different folders since teh *.csv file or files are in the source or at the push d folder, yet it needs to be copied to the destination folder which is different.
The goal is to take all *.csv files and copy them to a new folder into a new file named amalgamated.csv
Hope this helps.
ASKER
Yes that's right the copy needs to be to a different folder to amalgamate the files.
Thanks again, will try this.
And also in this case you don't feel we need the pause?
ASKER
Ok thanks so much oBdA.. let me give it a try..
Hey, something like
Open in new window