AutoHotkey Community

It is currently May 26th, 2012, 10:09 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: October 19th, 2009, 7:13 pm 
Offline

Joined: September 13th, 2009, 2:34 pm
Posts: 30
Hi there!

I made a script which backups certain folders and it's contents and assigned a nice hotkey to launch it, no problem so far.

However, my friends are now asking me to give them the ability to choose multiple source and destination folders and have them all backupped at once. Here's an example of the script:

Code:
SetWorkingDir, %BrowseSource%
Loop, *.*, , 1
{
    CopySourcePattern = %A_LoopFileLongPath%
    CopyDest = %BrowseDest%
    IfNotExist, %CopyDest%\%A_LoopFileDir%
    FileCreateDir, %CopyDest%\%A_LoopFileDir%
    GuiControl,, MyProgress, 25  ; Increase the current position to 25.
    copy_it = n
    IfNotExist, %CopyDest%\%A_LoopFileFullPath%  ; Always copy if target file doesn't yet exist.
        copy_it = y
    else
    GuiControl,, MyProgress, 50  ; Increase the current position to 50.
    {
        FileGetTime, time, %CopyDest%\%A_LoopFileName%
        EnvSub, time, %A_LoopFileTimeModified%, seconds  ; Subtract the source file's time from the destination's.
        if time < 0  ; Source file is newer than destination file.
            copy_it = y
    }
    if copy_it = y
    {
        FileCopy, %A_LoopFileLongPath%, %CopyDest%\%A_LoopFileFullPath%, 1   ; Copy with overwrite=yes
        if ErrorLevel
            MsgBox, Could not copy "%A_LoopFileFullPath%" to "%CopyDest%\%A_LoopFileFullPath%".
    }
    GuiControl,, MyProgress, 100  ; Increase the current position to 100.
}


I can, of course, add extra buttons, assign them the variable BrowseSource2 e.g. and copy and paste this example above again but change BrowseSource to BrowseSource2. This however seems a rather complicated way of doing things.

I'd like to be able to let the user choose for himself how many folders he wants to backup without me having to copy/ paste these lines over and over again..

BTW; BrowseSource is determined by a 'Select source' button in the main GUI which opens a FileSelectFolder who's output is stored in BrowseSource.

Thanks ahead!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 19th, 2009, 7:32 pm 
Offline

Joined: August 22nd, 2009, 11:23 pm
Posts: 294
There are quite a few BACKUP programs already developed by
forum members.

Do a forum search on words like "Backup", "Backup+folder"
"backup+files"and various combinations.

Here are a few examples:
http://www.autohotkey.com/forum/topic7989.html
http://www.autohotkey.com/forum/topic42839.html
http://www.autohotkey.com/forum/topic14 ... lder+files
http://www.autohotkey.com/forum/topic57 ... lder+files
http://www.autohotkey.com/forum/topic17 ... lder+files

Have Fun :lol:

_________________
Image
"Man's quest for knowledge is an expanding series whose limit is infinity"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 19th, 2009, 7:53 pm 
Offline

Joined: September 13th, 2009, 2:34 pm
Posts: 30
hi txquestor, thanks for the suggestions!

I know there are a lot of backup utilities already out there but I learned (and am still learning) SO much from writing my own I'd like to continue with my own one..

If only I knew how to give a user unlimited source and destination choices so he/ she can backup everything in 1 go..

For example, I'm not only programming scripts, I also make music in Cubase 5, edit pictures or movies in Adobe CS4 and have a lot of files in a lot of different places. This way, I could make a backup of ALL those files in 1 go to my NAS..

I wrote the script that it stores all the sources and destinations (stopped copy/ pasting after 2 ;-)) in an INI file so the next time you use the Hotkey it asks you to backup the default folders and goes ahead after pressing Yes..

Thanks again!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 19th, 2009, 9:37 pm 
Offline

Joined: August 22nd, 2009, 11:23 pm
Posts: 294
You also learn alot by dissecting other's scripts.
Especially if they already work.

All the functions you need to accomplish your own goal
are problably already discussed & written about.

Don't ignore that resource because you want to DO IT SELF.
My daughter used to say that when she was a baby.

Any how, one of the ways that I leaned besides experimenting with each command.
Was to take a snippet of code someone wrote and dissect it line by line
and write a comment next to it explaining how it works.
Then if I couldn't figure it out, I'd ask the forum.

Doing what you want is no small task with all the flexibility you want.
But go after it :!: :!: :roll:
Have Fun :lol:

_________________
Image
"Man's quest for knowledge is an expanding series whose limit is infinity"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 20th, 2009, 9:50 am 
you need to learn how to use functions, tkae a look in the help file!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 20th, 2009, 10:13 am 
Offline

Joined: February 22nd, 2009, 7:51 pm
Posts: 47
Location: Poland
Maybe some parts of my ToDo program will help you - take a look.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 20th, 2009, 7:29 pm 
Offline

Joined: August 22nd, 2009, 11:23 pm
Posts: 294
Hi Vifon,

I understand how your Backup example works.

I don't understand what your ToDo.ahk example has to do with backups.

As far as your users wanting the flexibility of adding files/folders of their choice to the auto backup all at once idea.

The commands FileSelectFolder, FileSelectFile, FileCopyDir, FileMoveDir, FileCopy & FileMove
all provide the method to collect files/folders & copymove them wherever you want to do your backup. Either store the locations in a file or variable.

I would suggest talking to your users and write a little specification of features.
Because without it I don't know how to code something or suggest an approach beyond what you already defined.

Example.
Is the backup location fixed or user choice?

As you can see, your approach to coding is very different depending on which method you chosose.

My philosophy is any time more than one person is involved.
Interview & write a specification and get everyone to agree on.
Otherwise, you run the risk of constantly changing the application.
This may cause a total different approach and you start from scratch again.

Another example is this forum.
You will see numerous times where someone started with an idea and
other forum users startied recommending features/changes.
Over a period of weeks or months it evolves into a finished program.

Is this what you want to do. Or start with a well defined approach,
code it. Review with users for final changes and you are done.

One is major the other is minor.

Good Luck, :roll: :oops: :lol:

_________________
Image
"Man's quest for knowledge is an expanding series whose limit is infinity"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 20th, 2009, 10:29 pm 
Offline

Joined: February 22nd, 2009, 7:51 pm
Posts: 47
Location: Poland
txquestor wrote:
I understand how your Backup example works.

I don't understand what your ToDo.ahk example has to do with backups.
I didn't mean the backup part (I think it is unnecessary now but I'm too lazy to delete it). I meant that it has variable number of rows. I thought it would help.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google [Bot], hyper_, JSLover, Leef_me, oldbrother, patgenn123 and 61 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group