Batch script to copy files !!

Discussion in 'Software' started by simplyeshu, Feb 4, 2012.

  1. simplyeshu

    simplyeshu Private E-2

    Hello Frens,

    I have written a small batch script to move the files from two directories to one main directory. It should record all the activities in a log file like files have been moved successfully from directory b to directory A and total number of files moved along with timestamp but its not working. Can you please review and help? Appreciate your help. Also tell me if we can automate this to run everyday at particular time (between 10pm - 11pm)

    echo "files moving at "%date%-%time%" >> c:\OutputFile.log
    move "C:\A\*.*" "C:\Test" >> C:\OutputFile.log
    move "C:\B\*.*" "C:\Test" >> C:\OutputFile.log
    echo "files moved at "%date%-%time%" >> c:\outputfile.log
     
  2. FineJungThingy

    FineJungThingy Private E-2

    You didn't specify exactly what "...it's not working." means. When I run that code, it does move the files, and does write to the logfile.

    Be aware that without /Y in the command, the job will require manual input if/when duplicate filename(s) exist.

    What operating system are you running this on?

    If it is still not working, then explain exactly what about it is not working. Do any error or warning messages appear? Are you running this on a Windows platform, and if so, are you running the code from within a command-prompt session, directly in Windows, how?

    As for automating it, the answer is Yes it can be automated. It depends partly on what operating system you are using. If it is some version of Windows, you can use the Windows Task Scheduler. There are many helpful pages on the internet that explain how to use it, such as these:

    http://www.iopus.com/guides/winscheduler.htm

    http://en.wikipedia.org/wiki/Windows_Task_Scheduler

    NOTE that the scheduler varies somewhat with different versions of the operating system. You must know what platform you are working with, and seek information specific to your working platform.

    NOTE also that some "security" applications can block tasks from being launched unless they have been registered ahead of time with said application. Test, test, test.

    There are also 3rd-party applications you can buy that will automate tasks. Some are more powerful and easier to use than the Windows Task Scheduler. But for many purposes (most?), the Windows Task Scheduler works fine.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds