Sign in to follow this  
Followers 0
chaitanyagutala

Script for Copying or Moving data over network

2 posts in this topic

Hi all ,

I am new to autoit script and I need small help in the following script . I have written a script which would copy or move data over the network or in the same system(between drives). But there is only one problem with it. Even if I choose copy option also, it is going for moving data only.I am giving you the script now.Please check and give me some suggestions.

#include <GUIConstantsEx.au3>

;Opt(('MustDeclareVars', 1)

Global $tt,$menu1,$n1,$n2

$tt = GUICreate("Data Modifier",250,200,500,250)

$menu1 = GUICtrlCreateMenu("Modify in two ways:")

$n1 = GUICtrlCreateList("", 10, 10, -1, 100)

GUICtrlSetData(-1, "Copy|Move", "")

$n2 = GUICtrlCreateButton("OK", 10, 110, 50)

GUICtrlSetState(-1, $GUI_FOCUS)

GuiSetState()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $n2

$menustate = GUICtrlRead($menu1) ; return the state of the menu item

If $menustate = "Copy" Then

$file = InputBox("Source for copying","Give the exact path of the Source with \ at the end ")

if @error = 1 Then

MsgBox(0,"Exit","Data Not Modified")

Exit

EndIf

$file1 = InputBox("Destination","Give the destination path ")

if @error = 1 Then

MsgBox(0,"Exit","Data Not Modified")

Exit

EndIf

DirCopy($file,$file1,1)

MsgBox(0,"Done","Data Copying Completed")

Else

$file = InputBox("Source","Give the exact path of the Source with \ at the end ")

if @error = 1 Then

MsgBox(0,"Exit","Data Not Modified")

Exit

EndIf

$file1 = InputBox("Destination","Give the destination path ")

if @error = 1 Then

MsgBox(0,"Exit","Data Not Modified")

Exit

EndIf

DirMove($file,$file1,1)

MsgBox(0,"Done","Data Moving Completed")

Exit

EndIf

EndSelect

WEnd


ChaitanyaKumar GI dont make mistakes.I just have learning.I have no special talents. I am only passionately curious.

Share this post


Link to post
Share on other sites



Hi all ,

I am new to autoit script and I need small help in the following script . I have written a script which would copy or move data over the network or in the same system(between drives). But there is only one problem with it. Even if I choose copy option also, it is going for moving data only.I am giving you the script now.Please check and give me some suggestions.

#include <GUIConstantsEx.au3>

;Opt(('MustDeclareVars', 1)

Global $tt,$menu1,$n1,$n2

$tt = GUICreate("Data Modifier",250,200,500,250)

$menu1 = GUICtrlCreateMenu("Modify in two ways:")

$n1 = GUICtrlCreateList("", 10, 10, -1, 100)

GUICtrlSetData(-1, "Copy|Move", "")

$n2 = GUICtrlCreateButton("OK", 10, 110, 50)

GUICtrlSetState(-1, $GUI_FOCUS)

GuiSetState()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $n2

$menustate = GUICtrlRead($menu1) ; return the state of the menu item

If $menustate = "Copy" Then

$file = InputBox("Source for copying","Give the exact path of the Source with \ at the end ")

if @error = 1 Then

MsgBox(0,"Exit","Data Not Modified")

Exit

EndIf

$file1 = InputBox("Destination","Give the destination path ")

if @error = 1 Then

MsgBox(0,"Exit","Data Not Modified")

Exit

EndIf

DirCopy($file,$file1,1)

MsgBox(0,"Done","Data Copying Completed")

Else

$file = InputBox("Source","Give the exact path of the Source with \ at the end ")

if @error = 1 Then

MsgBox(0,"Exit","Data Not Modified")

Exit

EndIf

$file1 = InputBox("Destination","Give the destination path ")

if @error = 1 Then

MsgBox(0,"Exit","Data Not Modified")

Exit

EndIf

DirMove($file,$file1,1)

MsgBox(0,"Done","Data Moving Completed")

Exit

EndIf

EndSelect

WEnd

Hi Chaitu,

A small mistake you had done at:

Case $msg = $n2

$menustate = GUICtrlRead($menu1) ; return the state of the menu item

After OK button, clicked you need to read from list and not from menu. So correct it as follows and it will work:

Case $msg = $n2

$menustate = GUICtrlRead($n1) ; return the state of the menu item

Also, my suggession during MOVE operation is to use FILECOPY() command instead of DIRCOPY().

Have a good day dude.

-regards,

Ramesh K

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0