Jump to content

File bkp to another folder ...


 Share

Recommended Posts

Good Morning!

Thanks to this script below, based on an excellent script provided to me for another use from a kind AI user here, I'm making backups of a vital log file that I currently have responsibility for. My question is how to modify it to add the path to the current user path's desktop. I'd prefer to have the bkp copies go to my desktop than to the same folder the log resides in.

I learned a few days ago that somehow using @UserProfileDir seems to do the trick when trying to get a script that will work no matter what system you're one with different profiles; but I'm such a dork re scripting (as anyone who has ever helped me in this great AI help forum knows! <g>) that I haven't managed to get a copy to go to other than the original file as that is what the code to the original script does.

I was able to figure out how to successfully modify the original script syntax given to me to fit the current need. So was real happy I could do that much <g>:

;
; AutoIt v3.0
;
AutoItSetOption("WinTitleMatchMode", 2)     ; this allows partial window titles to be valid!


$file = "G:\Account\Invlog1.xls"
$fileDir = Stringleft($file, StringInStr($file, "\", 0, -1) - 1)    ; ALL up to (but not including) the last backslash
$fileName = StringRight($file, StringLen($file) - StringInStr($file, "\", 0, -1))   ; what's left after last backslash
;$file2 = $fileDir & "\" & $fileName & " - BKP- " & @YEAR & "." & @MON & "." & @MDAY & ", " & @HOUR & "h" & @MIN & ".xls"
$file2 = $fileDir & "\" & $fileName & " - BKP- " & @YEAR & "." & @MON & "." & @MDAY & ", " & @HOUR & "h" & @MIN & "m" & @SEC & "s" & ".xls"
FileCopy($file, $file2)


Sleep(100)
Send("{F5}")


Exit
; finished
It's just that every attempt to put @UserProfileDir and desktop didn't work. I'd like to make copies to my own desktop because my colleagues will not understand why I have multiple date- and time-stamped copies of the invoice log! <g>

Hope I explained clearly enough. Thanks; appreciate it very much! :)

Link to comment
Share on other sites

I think i got your question. To get the path to the desktop look in the helpfile at "macros" look at

@DesktopDir

~cdkid

AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!
Link to comment
Share on other sites

I think i got your question. To get the path to the desktop look in the helpfile at "macros" look at

@DesktopDir

~cdkid

<lol> Darn, I missed again.

Thanks re the @DesktopDir. One of the big problems is that I don't know where to put the code in and amongst the script ... ! <g> I even tried putting the real, full desktop path in for the current computer they put me on but nothing worked <g>. [Toldyas I had troubles with scripting <chuckle>.] Believe it or not, I am improving with all this stuff, but with ones like this haven't yet grasped all the ins and outs of all the variables.

Cheers. :)

Link to comment
Share on other sites

Good Morning!

Thanks to this script below, based on an excellent script provided to me for another use from a kind AI user here, I'm making backups of a vital log file that I currently have responsibility for. My question is how to modify it to add the path to the current user path's desktop. I'd prefer to have the bkp copies go to my desktop than to the same folder the log resides in.

I learned a few days ago that somehow using @UserProfileDir seems to do the trick when trying to get a script that will work no matter what system you're one with different profiles; but I'm such a dork re scripting (as anyone who has ever helped me in this great AI help forum knows! <g>) that I haven't managed to get a copy to go to other than the original file as that is what the code to the original script does.

I was able to figure out how to successfully modify the original script syntax given to me to fit the current need. So was real happy I could do that much <g>:

;
; AutoIt v3.0
;
AutoItSetOption("WinTitleMatchMode", 2)     ; this allows partial window titles to be valid!
$file = "G:\Account\Invlog1.xls"
$fileDir = Stringleft($file, StringInStr($file, "\", 0, -1) - 1)    ; ALL up to (but not including) the last backslash
$fileName = StringRight($file, StringLen($file) - StringInStr($file, "\", 0, -1))   ; what's left after last backslash
;$file2 = $fileDir & "\" & $fileName & " - BKP- " & @YEAR & "." & @MON & "." & @MDAY & ", " & @HOUR & "h" & @MIN & ".xls"
$file2 = $fileDir & "\" & $fileName & " - BKP- " & @YEAR & "." & @MON & "." & @MDAY & ", " & @HOUR & "h" & @MIN & "m" & @SEC & "s" & ".xls"
FileCopy($file, $file2)
Sleep(100)
Send("{F5}")
Exit
; finishedoÝ÷ ÙCS$Ä
Ú'ßÛaj÷ºÚ"¶í+¢jnµêì¢'mµë-Ù^¶g¤
!Âbº$²'âµÚ²}ý¶ÚòuæØb±Êy«­¢+ٵͽà ØаÌäìÌäì°ÀÌØí½Á¥°

~cdkid

AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!
Link to comment
Share on other sites

Hi, you are very kind. Thanks for the help.

The difficulty is that the original script I posted above does exactly what's needed _except_ regarding where it dumps the copy file. The script adds a date and time stamp -- which includes hour, minutes and seconds -- to the file which is needed because these are backups.

The problem with all the variables within the script is that I don't know where to put the @DesktopDir - or whatever code is needed to make the copy to the desktop - so that it still performs the file copy _with_ the date and time stamp yet directs it to the current desktop. This script just does all this to the same folder the invlog1.xls file is located.

I'll keep trying. After yesterday thinking I'd accidentally deleted an entire column in this spreadsheet and the panic that wrought, I'm backing up this file rather frequently and then moving it to the desktop. However, would just be easier to add the path within the script itself. (Turns out the finger fumble merely hid the column, but you can imagine the panic!! <g>)

Thanks!!! :)

Link to comment
Share on other sites

In the script from your 1st post, just change

$fileDir = Stringleft($file, StringInStr($file, "\", 0, -1) - 1)

to

$fileDir = @DesktopDir

Ah, geez, no wonder!! <g> I didn't change enough in my trials when trying to modify this <sigh>.

YIPPEEE, thanks!!

I changed the script to this:

;
; AutoIt v3.0
;
AutoItSetOption("WinTitleMatchMode", 2)     ; this allows partial window titles to be valid!


$file = "G:\Account\Invlog1.xls"
; to make copy go to same folder, use syntax:  $fileDir = Stringleft($file, StringInStr($file, "\", 0, -1) - 1)
; to make copy go to the desktop,
;   no matter the profile, use syntax:         $fileDir = @DesktopDir
$fileDir = @DesktopDir    ; ALL up to (but not including) the last backslash
$fileName = StringRight($file, StringLen($file) - StringInStr($file, "\", 0, -1))   ; what's left after last backslash
;$file2 = $fileDir & "\" & $fileName & " - BKP- " & @YEAR & "." & @MON & "." & @MDAY & ", " & @HOUR & "h" & @MIN & ".xls"
$file2 = $fileDir & "\" & $fileName & " - BKP- " & @YEAR & "." & @MON & "." & @MDAY & ", " & @HOUR & "h" & @MIN & "m" & @SEC & "s" & ".xls"
FileCopy($file, $file2)


Sleep(100)
Send("{F5}")


Exit
; finished

Works fantastic!

One last thing, for future use, what if we need to make a copy using this script to a folder on the current desktop instead, say something like a folder called ...DESKTOP\BACKUPS, how would we modify the above for that?

Thank you, thank you! I really appreciate this. :)

Link to comment
Share on other sites

Then istead of

$fileDir = @DesktopDir

it would be

$fileDir = @DesktopDir & "\BACKUPS"

Very kewl. I ended up changing the script to go to a backups folder as it seemed a better thing to do. Here's the new script:
;
; AutoIt v3.0
;
AutoItSetOption("WinTitleMatchMode", 2)     ; this allows partial window titles to be valid!


$file = "G:\Account\Invlog1.xls"

; to make copy go to same folder, use syntax:  $fileDir = Stringleft($file, StringInStr($file, "\", 0, -1) - 1)
; to make copy go to the desktop,
;   no matter the profile, use syntax:         $fileDir = @DesktopDir
; for a folder on any desktop, use syntax:     $fileDir = @DesktopDir & "\BACKUPS" (replacing in quotes w/name of your folder)

$fileDir = @DesktopDir & "\INVLOG.XLS backups"    ; ALL up to (but not including) the last backslash
$fileName = StringRight($file, StringLen($file) - StringInStr($file, "\", 0, -1))   ; what's left after last backslash
;$file2 = $fileDir & "\" & $fileName & " - BKP- " & @YEAR & "." & @MON & "." & @MDAY & ", " & @HOUR & "h" & @MIN & ".xls"
$file2 = $fileDir & "\" & $fileName & " - BKP- " & @YEAR & "." & @MON & "." & @MDAY & ", " & @HOUR & "h" & @MIN & "m" & @SEC & "s" & ".xls"
FileCopy($file, $file2)


Sleep(100)
Send("{F5}")


Exit
; finished
Others might find it useful.

Thanks! :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...