Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

how to overwrit an existing file when make FileCopy


  • Please log in to reply
7 replies to this topic
Zivo
  • Members
  • 14 posts
  • Last active: May 29 2019 12:08 AM
  • Joined: 15 Nov 2013

Hey All

 

i use this script to send file to a dropbox folder

 

#insert::
clipboard = ; Empty the clipboard
send , ^c
ClipWait,5 ; wait for the text or files to be copied to the clipboard
file = %Clipboard%
FileCopy , %file% , E:\My Documents\My Dropbox\Client\Ads  ; Copy the file to new location
sleep , 200
exist = %ErrorLevel% ; get the error level 0 = no errors
if exist > 0 ; what to do if there is an error like filename already exists
{
    ??????; i want to overwrite the existing file
}
return

 

beacuse i am uploading a file and than i fix something and want to upload it again how do i overwrite it ?

why cant  i use this script for multiple files only one at a time ?

 

Thanks



Zivo
  • Members
  • 14 posts
  • Last active: May 29 2019 12:08 AM
  • Joined: 15 Nov 2013

Anyone?



Zivo
  • Members
  • 14 posts
  • Last active: May 29 2019 12:08 AM
  • Joined: 15 Nov 2013

am i in the right place to post this kind of question ?



jNizM
  • Members
  • 928 posts
  • Last active: Jan 12 2018 09:23 AM
  • Joined: 01 Aug 2012
http://www.autohotke...ds/FileCopy.htm
FileCopy, SourcePattern, DestPattern [, Flag]

Flag 0 = (default) do not overwrite existing files
Flag 1 = overwrite existing files

[AHK] 1.1.27.04 x64 Unicode | [WIN] 10 Pro (Version 1709)
My GitHub Profile | Donations are appreciated if I could help you

nnnik
  • Members
  • 1625 posts
  • Last active: Jan 24 2019 02:19 PM
  • Joined: 28 Jul 2012

 

 

am i in the right place to post this kind of question ?

No you might want to use the I need Help Forum.


Visit the new forum ahkscript.org.

http://ahkscript.org


Zivo
  • Members
  • 14 posts
  • Last active: May 29 2019 12:08 AM
  • Joined: 15 Nov 2013

Thanks jNizM

 

it works

 

#insert::
clipboard = ; Empty the clipboard
send , ^c
ClipWait,5 ; wait for the text or files to be copied to the clipboard
file = %Clipboard%
FileCopy , %file% , E:My Dropbox\Ads  ; mvoes the file to new location
sleep , 200
exist = %ErrorLevel% ; get the error level 0 = no errors
if exist > 0 ; what to do if there is an error like filename already exists
{
FileCopy , %file% , E:My Dropbox\Ads ,1
}
return

 

one more question to improve this since i already have a condition in the code

can i make an alert messege that alerts me when i am going to overwrite a file and let me choose to overwrite or cancel,

 

Thanks



Morpheus
  • Members
  • 475 posts
  • Last active: Oct 21 2014 11:08 AM
  • Joined: 31 Jul 2008

www.autohotkey.com/docs/commands/MsgBox.htm


Any code that I post will be for AHK Basic.
I'm not always right, but I still try to help.

Zivo
  • Members
  • 14 posts
  • Last active: May 29 2019 12:08 AM
  • Joined: 15 Nov 2013

Thanks a lot

here is my final code i find it very useful for people who need to transfer files to a dropbox folder Often

 

#insert::
clipboard = ; Empty the clipboard
send , ^c
ClipWait,5 ; wait for the text or files to be copied to the clipboard
file = %Clipboard%
FileCopy , %file% , E:My Dropbox\Ads  ; mvoes the file to new location
sleep , 200
exist = %ErrorLevel% ; get the error level 0 = no errors
if exist > 0 ; what to do if there is an error like filename already exists
{
  MsgBox, 49,File already exist, The File you are trying to copy is already exist,`nDo you want to Overwrite the file?
    IfMsgBox OK
    FileCopy , %file% , E:\My Documents\My Dropbox\HolmesPlace Light\Ads ,1
}
return