Automate moving files with Task Scheduler and robocopy?

Page 2 of 2 FirstFirst 12

  1. Posts : 75
    Windows 10 Pro x64, Microsoft Bob
    Thread Starter
       #11

    Well, not so fast...

    The four files are being downloaded to the desktop and they are being moved. That part's good.

    However, the files remain on the desktop until the task repeats again 24 hours later. Then they are moved to their intended destination. I wanted the files to go into their destination immediately after they're downloaded so that I never see them on the desktop (unless I look really quickly at 3:33 am)

    The Last Run Result for that task shows (0x2). I looked that up but couldn't make any sense of what I found, which was mostly references to Windows 7.

    The screenshot three posts above shows the task's actions. See additional screenshot and the .bat files below.

    To sum up the question: How to get the four downloaded files to immediately leave the desktop and go to their destination?

    I looked really hard at this problem and cannot figure out what's wrong. The answer is probably really obvious but 'obvious' often escapes me.

    The following is exactly the contents of each .bat file...

    In toodledo_backup.bat:

    start "" www.toodledo.com/tools/backup.php
    start "" www.toodledo.com/tools/csv.php
    start "" www.toodledo.com/tools/csv.php?completed=1
    start "" www.toodledo.com/tools/csv_notes.php


    In toodledo_move.bat:

    robocopy "C:\Users\snive\desktop" "C:\Users\%username%\AppData\backup_auto_delete\toodledo" "toodledo_back_*.xml" "toodledo_completed_*.csv" "toodledo_current_*.csv" "toodledo_notebook_*.csv" /mov

    Automate moving files with Task Scheduler and robocopy?-ss_task_scheduler-2.png
      My Computers


  2. Posts : 16,976
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #12

    In Task scheduler, look on the right-hand side and Enable all tasks history. That might give you some additional info on the 0x2 result.
    Result 0x2 can mean that a file was not found. This might be because the file does not exist or because you do not have access to it / its folder.
    I would only expect to see it in Task scheduler if it could not find the files containing the actions [your batch files] which is clearly not the case.

    Do your 4
    start "" toodlepip
    download commands run sequentially [the first download completes before the next one starts downloading] or in parallel [the first ones starts downloading then the second one starts & so on]?
    - I think they run in parallel and your batch file toodledo_backup.bat therefore completes when the 4th line is started [not when the 4th line completes downloading].
    - So action 2 [toodledo_move.bat] runs as soon as toodledo_backup.bat completes, i.e. when all 4 downloads are started not when they are finished, so there is nothing to move yet.

    You could test this out by adding a last line to toodledo_backup.bat
    Code:
    Pause
    then waiting until you could see that the downloads had completed before you Press any key to continue . . .

    If I'm right then I think you need to test for completion of the downloads before starting the move. I don't know what to suggest as I do not know how your downloads behave.
    - Since your downloads can have a variety of names, you cannot use a simple test based on, perhaps, a Dir command to find out if they have all completed.
    - Since your downloads happen in parallel, there wouldn't seem to be any fixed event to determine that they had all completed.
    It seems to me that toodledo_move.bat needs to start off with a command for a very long wait instead - for example,
    Code:
    TimeOut /T 900
    which is 900 secs, 15 mins.
    Is there nothing in your downloads that might be used as a basis for a completion test?

    I find the use of both the fixed username snive and %username% very odd.

    By the way, I have never before noticed somebody deliberately putting files into an AppData folder.

    All the best,
    Denis
      My Computer


  3. Posts : 75
    Windows 10 Pro x64, Microsoft Bob
    Thread Starter
       #13

    Do your 4 start "" toodlepip download commands run sequentially
    Yes. I used 'Pause' and ran the task manually. After I pressed any key to continue, the four files were moved as intended.

    I tested the _backup.bat several times and it took a range of 2 to 5 seconds for the files to download. The largest of the four files is about 150 Kb.

    I edited the _move.bat to include TimeOut /T 12 and tested it. I ran the task manually and it completed successfully. I shall leave it like that unless there's a reason not to.

    I find the use of both the fixed username snive and %username% very odd.
    That's because I already had the 'snive' part and then (earlier in this thread) the suggested code was "C:\Users\%username%\desktop". Because I don't know what I'm doing , I took the suggestion as provided. Does %username% allow the task to run if someone other than myself was logged on?

    By the way, I have never before noticed somebody deliberately putting files into an AppData folder.
    I wanted to put the backup files in a place that made sense to me and, well, it is kind of app data. But I wasn't entirely satisfied with that choice and I'm open to a suggestion of a more appropriate location for those backed up files.

    Thank you for your time!
      My Computers


  4. Posts : 16,976
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #14

    main bit
    I'm glad that's resolved.
    I've got a couple of scripts that rely on timings to work and I'm never completely comfortable about them. I'm glad that it's working in your case.
    Now that you have it working, consider securing your scripts in a protected folder as I do - Set up my Tools folder ditty - TenForums

    snive bit - "if someone other than myself was logged on?"
    They would need access to snive's user folders. You would not normally grant that.
    I assume you need to be logged in to snive for your online app to work & the downloads to happen. I assume your online app password is saved by your browser so you log into that automatically.
    Your online app probably finds the Desktop of the currently-in-use user automatically so if you started using a different user account and saved your online app's password in the browser of another user it would save to its Desktop instead.
    If you want to be flexible then use %UserName% in place of snive. If not then use snive in both places.

    AppData bit
    "appropriate" depends on your backup strategy. I backup named subfolders within my Documents folder [to avoid subfolders put there by annoying applications e.g. …\Documents\Samsung].
    As long as the folder you are putting your files in is backed up then it is "appropriate".
    - I'd create something like …\Documents\ToodledoBackups and move the files there then add that path to my backup script.

    All the best,
    Denis
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 11:34.
Find Us




Windows 10 Forums