Code Monkey home page Code Monkey logo

go-robocopy's Introduction

Go Report Card Static Badge

go-robocopy

Disclaimer

This is an unofficial wrapper for robocopy. There is no affiliation with Microsoft or any of its subsidiaries in any way. Use it at your own risk.


Robocopy or Robust File Copy is a command line tool developed by Microsoft for copying files and directories from one location to another.

This is an unofficial wrapper written in Go to programmatically produce a robocopy command and execute it.

Important

This library can only be compiled for Windows targets as it relies on the robocopy command.

Installation

You can install the package using the go get command.

go get github.com/aggellos2001/go-robocopy

After that you need to import the module in your code.

import (
    gorobocopy "github.com/aggellos2001/go-robocopy"
)

Examples

You can create a new command instance by calling the NewRobocopy constructor:

cmd := gorobocopy.NewRobocopy(
    "C:\\source",
    "D:\\destination",
    "*.*",
)

You can then set some options for the command:

cmd.SetCopyOptions(&gorobocopy.CopyOptions{
    E:    true,
    Mt:   4,
    Copy: copyflags.D | copyflags.A | copyflags.T,
    }
)

Finally, you can execute the command. You can specify the stdin, stdout and stderr in the parameters or leave them as nil if you want to suppress the console input/output.

cmd.Run(nil,nil,nil)

You can also get the command object and call it yourself however you like. It returns a pointer to a *exec.Cmd object.

cmd.GetCommand()

Also you can get the slice containing all the arguments to manually create the command if you please.

cmd.GetCommandArgs()

go-robocopy's People

Contributors

aggellos2001 avatar

Watchers

 avatar

Forkers

patri-png

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.