probedrone Posted September 5, 2006 Posted September 5, 2006 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?
Moderators SmOke_N Posted September 5, 2006 Moderators Posted September 5, 2006 The regular FileCopy() in the help file with that option doens't benefit you? 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.
Matz Posted September 5, 2006 Posted September 5, 2006 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
Developers Jos Posted September 5, 2006 Developers Posted September 5, 2006 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() SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Moderators SmOke_N Posted September 5, 2006 Moderators Posted September 5, 2006 Sure, just remove the ",$FOF_RESPOND_YES" and it will prompt you to overwrite the file.For the directory creation, just use DirCreate() Jdeb, what does 32 do? It seems to be the only one missing, or am I opening a can of worms? 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.
Developers Jos Posted September 5, 2006 Developers Posted September 5, 2006 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 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
probedrone Posted September 5, 2006 Author Posted September 5, 2006 Where is $FOF_SIMPLEPROGRESS ever used?
Developers Jos Posted September 5, 2006 Developers Posted September 5, 2006 (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 September 5, 2006 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
probedrone Posted September 5, 2006 Author Posted September 5, 2006 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 filesEndif
Developers Jos Posted September 5, 2006 Developers Posted September 5, 2006 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 filesEndifUse FileExist() to test if it already exists .. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
probedrone Posted September 5, 2006 Author Posted September 5, 2006 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?
probedrone Posted September 5, 2006 Author Posted September 5, 2006 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)
Developers Jos Posted September 5, 2006 Developers Posted September 5, 2006 I have the same problem.... none of the options work . I am prett sure I had that working one time ... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Moderators SmOke_N Posted September 5, 2006 Moderators Posted September 5, 2006 You 2 didn't try 32 for spite did you 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.
probedrone Posted September 5, 2006 Author Posted September 5, 2006 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...
Developers Jos Posted September 5, 2006 Developers Posted September 5, 2006 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.... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
probedrone Posted September 5, 2006 Author Posted September 5, 2006 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 hahamight 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
probedrone Posted September 6, 2006 Author Posted September 6, 2006 Ok...according to this page:http://support.microsoft.com/?kbid=835926wildcards 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?
Developers Jos Posted September 6, 2006 Developers Posted September 6, 2006 Ok...according to this page:http://support.microsoft.com/?kbid=835926wildcards 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... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now