none
pausing script until file move is complete RRS feed

  • Question

  • I'm writing another media playback automation script.  At on point in the script I need to move a video file from one directory to another using the "move-item" command.  Immediately following that, I'll need to run a process called "MediaInfo.exe" to read the duration of the video file.  I need to make sure the file move is complete before attempting to read the duration of the file.  
    Can "wait-process" be used to pause the script until "move-item" is complete, or do I need another method.  I've used "wait-process" to insure completion of executables, but haven't tried it with powershell commands like "move-item".  Here's an excerpt from my untested script.  Will this arrangement work?

    if($v -ge 2){Move-Item -Path "s:\ntbscpg\temp\wsi forecast.wmv" -Destination "s:\ntbscpg\wsi forecast.wmv" -force}

    Wait-Process Move-Item  <-- This is what I'm unsure about...

    start-process mediainfo.exe ' --Inform=Video;%Duration% "s:\ntbscpg\wsi forecast.wmv"' -NoNewWindow -RedirectStandardOutput "s:\ntbscpg\videoduration.txt"

    Wait-Process mediainfo.exe

    $videoduration = get-content videoduration.txt
    echo 'Video duration is:' $videoduration


    Friday, March 13, 2015 2:19 PM

Answers

All replies