Sign in to follow this  
Followers 0
probedrone

How to modify this code?

19 posts in this topic

I found this really nice peice of code from JdeB

;~ 4 Do not display a progress dialog box.  
;~ 8 Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists.  
;~ 16 Respond with "Yes to All" for any dialog box that is displayed.  
;~ 64 Preserve undo information, if possible. 
;~ 128 Perform the operation on files only if a wildcard file name (*.*) is specified.  
;~ 256 Display a progress dialog box but do not show the file names.  
;~ 512 Do not confirm the creation of a new directory if the operation requires one to be created.  
;~ 1024 Do not display a user interface if an error occurs.  
;~ 2048 Version 4.71. Do not copy the security attributes of the file. 
;~ 4096 Only operate in the local directory. Don't operate recursively into subdirectories. 
;~ 9182 Version 5.0. Do not copy connected files as a group. Only copy the specified files.  

_FileCopy("C:\Installed Apps\Patches\WindowsXP-KB835935-SP2-ENU.exe","C:\temp")

Func _FileCopy($fromFile,$tofile) 
    Local $FOF_RESPOND_YES = 16
    Local $FOF_SIMPLEPROGRESS = 256
    $winShell = ObjCreate("shell.application")
    $winShell.namespace($tofile).CopyHere($fromFile,$FOF_RESPOND_YES)
EndFunc

Is there a way to set the options to choose between overwriting the files or not? Also, I want to be able to create the directory if the destination dir does not exist. Anyone know of a way to modify this to work?

Share this post


Link to post
Share on other sites



The regular FileCopy() in the help file with that option doens't benefit you?


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

I think the

;~ 16 Respond with "Yes to All" for any dialog box that is displayed.

gives you overwrite...

Have you tried the script?

Matz :P

Share this post


Link to post
Share on other sites

I found this really nice peice of code from JdeB

;~ 4 Do not display a progress dialog box.  
;~ 8 Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists.  
;~ 16 Respond with "Yes to All" for any dialog box that is displayed.  
;~ 64 Preserve undo information, if possible. 
;~ 128 Perform the operation on files only if a wildcard file name (*.*) is specified.  
;~ 256 Display a progress dialog box but do not show the file names.  
;~ 512 Do not confirm the creation of a new directory if the operation requires one to be created.  
;~ 1024 Do not display a user interface if an error occurs.  
;~ 2048 Version 4.71. Do not copy the security attributes of the file. 
;~ 4096 Only operate in the local directory. Don't operate recursively into subdirectories. 
;~ 9182 Version 5.0. Do not copy connected files as a group. Only copy the specified files.  

_FileCopy("C:\Installed Apps\Patches\WindowsXP-KB835935-SP2-ENU.exe","C:\temp")

Func _FileCopy($fromFile,$tofile) 
    Local $FOF_RESPOND_YES = 16
    Local $FOF_SIMPLEPROGRESS = 256
    $winShell = ObjCreate("shell.application")
    $winShell.namespace($tofile).CopyHere($fromFile,$FOF_RESPOND_YES)
EndFunc

Is there a way to set the options to choose between overwriting the files or not? Also, I want to be able to create the directory if the destination dir does not exist. Anyone know of a way to modify this to work?

Sure, just remove the ",$FOF_RESPOND_YES" and it will prompt you to overwrite the file.

For the directory creation, just use DirCreate()

:P


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Sure, just remove the ",$FOF_RESPOND_YES" and it will prompt you to overwrite the file.

For the directory creation, just use DirCreate()

:P

Jdeb, what does 32 do? It seems to be the only one missing, or am I opening a can of worms?

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Jdeb, what does 32 do? It seems to be the only one missing, or am I opening a can of worms?

must be some MS secret ... its a cut&paste from http://windowssdk.msdn.microsoft.com/en-us...y/ms723207.aspx

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Where is $FOF_SIMPLEPROGRESS ever used?

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Where is $FOF_SIMPLEPROGRESS ever used?

It isn't in this example but could be "added" to the CopyHere parameter to show a different progress window:

$winShell.namespace($tofile).CopyHere($fromFile,$FOF_RESPOND_YES + $FOF_SIMPLEPROGRESS)
Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Sure, just remove the ",$FOF_RESPOND_YES" and it will prompt you to overwrite the file.

I want to set this option up as a function paramenter, so by adding RESPOND_YES it WILL overwrite the files, but if I just remove it, it prompts for user input. How do I just plainly do something like:

If $overwrite = 1 Then

$winShell.namespace($tofile).CopyHere($fromFile,$FOF_RESPOND_YES)

Elseif $overwrite = 0 Then

;dont overwrite the files

Endif

Share this post


Link to post
Share on other sites

I want to set this option up as a function paramenter, so by adding RESPOND_YES it WILL overwrite the files, but if I just remove it, it prompts for user input. How do I just plainly do something like:

If $overwrite = 1 Then

$winShell.namespace($tofile).CopyHere($fromFile,$FOF_RESPOND_YES)

Elseif $overwrite = 0 Then

;dont overwrite the files

Endif

Use FileExist() to test if it already exists .. :P

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Well if im copying over an entire directory I can only check if the dir exists. How can I check each file in that directory and if file exist, dont copy, else copy?

Share this post


Link to post
Share on other sites

wtf... I didnt do anything different but now this code keeps asking if I want to overwrite files... Its like $FOF_RESPOND_YES = 16 isnt working anymore...

_FileCopy("C:\test_tools\autoItInstall\*.*", "C:\test", 0, 1)

Func _FileCopy($fromFile, $toDir, $overWrite = 0, $createDir = 0)

If $createDir = 1 Then

If DirCreate($toDir) = 0 Then Msgbox(0, "ERROR", $toDir & @LF & "Directory cannot be created.")

EndIf

Local $FOF_RESPOND_YES = 16

Local $FOF_SIMPLEPROGRESS = 256

$winShell = ObjCreate("shell.application")

$winShell.namespace($toDir).CopyHere($fromFile, $FOF_RESPOND_YES)

EndFunc

(C:\test already contains the files from the autoItInstall folder)

Share this post


Link to post
Share on other sites

You 2 didn't try 32 for spite did you :P:nuke:


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

bloody hell! thought I found a great solution to all this... *sob* i dont wanna use those long ass progress bar codes that takes up half of my entire program...

Share this post


Link to post
Share on other sites

bloody hell! thought I found a great solution to all this... *sob* i dont wanna use those long ass progress bar codes that takes up half of my entire program...

As a workaround you could first do a FileDelete() and then the copy bit if you are looking for the progressbar....

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

As a workaround you could first do a FileDelete() and then the copy bit if you are looking for the progressbar....

lol then i might need a file delete progress bar! the cycle never ends haha

might just well just stick to the filecopy() in the help file and hope in the next version of autoit the progress bar option can be added

Share this post


Link to post
Share on other sites

Ok...according to this page:

http://support.microsoft.com/?kbid=835926

wildcards are not supported for this kind of copy method.

Its still a great method tho, so does anyone know how I can add something to the autoit script that lets me copy the entire contents of one folder into another, and overwrite if neccessary?

Share this post


Link to post
Share on other sites

Ok...according to this page:

http://support.microsoft.com/?kbid=835926

wildcards are not supported for this kind of copy method.

Its still a great method tho, so does anyone know how I can add something to the autoit script that lets me copy the entire contents of one folder into another, and overwrite if neccessary?

Yeap... that's it...

It works fine when a filename is specified.

So just use the FileFindFirstFile() and loop FileFindNextFile() to perform the Func _FileCopy($fromFile,$tofile) for each file in the directory...

:P


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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