John Curtiss (i hate the web admin) asked a question.

moveit ideas - New macros - Total files/bytes uploaded/downloaded

@Richard Auger (https://pro2col.com/)​ @Nathan Songer (Clayton Homes)​ 

 

wanted to discuss over here instead of in the ideas thread. curious why scripting won't work for this - Nathan brought up "if file count is zero, i don't want my script to run," but that's what the "run once after all downloads vs "run script on each file" option is for, right?

 

i personally have never required two separate lists of downloaded versus uploaded (is that for one source sending to multiple destinations? otherwise, unless there's a failure, everything should match?), so running the script below, per file, in a traditional task or at the source of an advanced task has sufficed for me. but theoretically if you change some variable names to make them unique across two versions of the script, you could run one version at the source of an advanced task and one at the destination(s). to get two versions of totalfileize and filecount. you guys can ignore [parm:table]

 

  1. #powershell produces a table of files with their individual sizes [parm:table], then a total file count [parm:filecount], and then a total byte count [parm:totalfilesize]
  2.  
  3. $Myorigname = $miaclient.mimacro("[origname]")
  4. $myfilesize = [int32]$miaclient.mimacro("[FileSize]")
  5.  
  6. $table = $miaclient.migettaskparam("Table")
  7. $row = $Myorigname + ", " + $myfilesize + " bytes"
  8.  
  9. if(!$table)
  10. {
  11. $miaclient.misettaskparam("Table",$row)
  12. }
  13. else
  14. {
  15. $miaclient.misettaskparam("Table",$table + "`n$row")
  16. }
  17.  
  18. $count = $miaclient.MIGetTaskParam("FileCount")
  19.  
  20. if(!$count)
  21. {
  22. $count = 1
  23. $miaclient.MISetTaskParam("FileCount",$count)
  24. }
  25. else
  26. {
  27. $count = [int32]$count + 1
  28. $miaclient.MISetTaskParam("FileCount",$count)
  29. }
  30.  
  31. $totalfilesize = [int32]$miaclient.migettaskparam("TotalFileSize")
  32.  
  33. if(!$totalfilesize)
  34. {
  35. $miaclient.misettaskparam("TotalFileSize",$myfilesize)
  36. }
  37. Else
  38. {
  39. $miaclient.misettaskparam("TotalFileSize",$totalfilesize + $myfilesize)
  40. }
  41.  

 

 

 


  • Nathan Songer (Clayton Homes)

    I have to string two tasks together to archive desired results.

    Task 1
    download zip files from sftp server
    move existing files from current folder to archive folder (PowerShell script)
    unzip files from sftp server (built in script)
    save extracted files to staging folder.

    Task 2
    download files from staging folder
    save files to destination share renamed based on 4 different name patterns

    The problem is task 1 is always successful from the first script that always runs. If there was a way to use the file count from the download step, I could use an if statement to control if the rest of the steps run. Then it would not report Task 1 as a success when there are no files from the sftp server.
  • John Curtiss (i hate the web admin)

    "move existing files to archive folder"

     

    I'm understanding thatto mean you want to archive the current files *in the final destination folder* If new zips are found on the source sftp server? And you're unzipping the new files into a staging folder first anyway, so you can safely do the unzip step before the archive step?

     

    Something along the lines of

     

    Download zips

    For each file

    - run my script

    - unzip into staging folder

    (back outside the foreach statement)

    If (parm:filecount >=1 AND taskstatus matches success )

    - run powershell script

    If (taskstatus matches success)

    - run task 2

     

    Then the script only runs if you actually find source zip files and successfully send them to the staging folder?