Source language: Translate to:

File Copy suggestion request

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

File Copy suggestion request

Postby BRobinsonS » Tue Jan 13, 2015 10:01 am

Using the code for menu option:
Code: Select all
FolderExists "[PubDir]Backup" "[BackupFolderExists]"
If "[BackupFolderExists]" "=" "False"
  CreateFolder "[PubDir]Backup"
Endif
FileCopy "[PubDir]AddressBook.mdb" "[PubDir]Backup\"


It works but I would like to attach perhaps an incremental number to the copied file so I have a series of backups.
Suggestions on how to do this?
Brian Robinson
'When all else fails, try again!'
www.ComputerSoftwareSystems.com
User avatar
BRobinsonS
 
Posts: 340
Joined: Sun Sep 25, 2005 9:00 pm
Location: Ontario, Canada

Re: File Copy suggestion request

Postby Gaev » Tue Jan 13, 2015 10:27 am

Brian Robinson:

It works but I would like to attach perhaps an incremental number to the copied file so I have a series of backups.
Suggestions on how to do this?

You might consider, instead of an incremental number, appending a date as a suffix ... so today's backup would look like AddressBook 20150113.mdb.

And if you have reason to do more than one backup per day, you could choose to ...

- first erase the previous backup file

... or ...

- add a timestamp to the name e.g. AddressBook 20150113 122535.mdb
User avatar
Gaev
 
Posts: 3735
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: File Copy suggestion request

Postby BRobinsonS » Tue Jan 13, 2015 10:48 am

My first inclination was date.
I guess that was my question "how do I append the date to the file name?"

What variable do I use or how do I get the 20150113 format so I get AddressBook 20150113.mdb ?
Brian Robinson
'When all else fails, try again!'
www.ComputerSoftwareSystems.com
User avatar
BRobinsonS
 
Posts: 340
Joined: Sun Sep 25, 2005 9:00 pm
Location: Ontario, Canada

Re: File Copy suggestion request

Postby HPW » Tue Jan 13, 2015 10:53 am

You can cut it out of:

[DateShort] = The current date in Windows’ short format (10/22/07).
Hans-Peter
User avatar
HPW
 
Posts: 2520
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Re: File Copy suggestion request

Postby Neosoft Support » Tue Jan 13, 2015 12:01 pm

You could also do something like this:

FileCopy "[PubDir]AddressBook.mdb" "[PubDir]Backup\AddressBook[Year][MonthNum][DayNum].mdb"

[Year], [MonthNum] and [DayNum] are global variables.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5603
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Re: File Copy suggestion request

Postby Gaev » Tue Jan 13, 2015 12:18 pm

What Dave said ... plus you might allow for the single digit months and days with ...
Code: Select all
If "[MonthNum]" "<" "10"
    SetVar "[thisMonth]" "0[MonthNum]"
Else
    SetVar "[thisMonth]" "[MonthNum]"
EndIf
If "[DayNum]" "<" "10"
    SetVar "[thisDay]" "0[DayNum]"
Else
    SetVar "[thisDay]" "[DayNum]"
EndIf
...AlertBox "Year,Month,Day" "[Year][thisMonth][thisDay]"
FileCopy "[PubDir]AddressBook.mdb" "[PubDir]Backup\AddressBook[Year][thisMonth][thisDay].mdb"


Always using 2 digits for months and days makes it easier to view filenames (e.g. sorted in say Windows Explorer) in chronological order.
User avatar
Gaev
 
Posts: 3735
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: File Copy suggestion request

Postby BRobinsonS » Tue Jan 13, 2015 12:26 pm

Once again thank you for the suggestions.

I like the last suggestion using [Year], [MonthNum] and [DayNum].
This allows me to build the appending string to add 0 if MonthNum or/and DayNum is less than 10 so I get 20150113 format and in year month day order.

As always Thank you for helping.
Brian Robinson
'When all else fails, try again!'
www.ComputerSoftwareSystems.com
User avatar
BRobinsonS
 
Posts: 340
Joined: Sun Sep 25, 2005 9:00 pm
Location: Ontario, Canada

Re: File Copy suggestion request

Postby BRobinsonS » Tue Jan 13, 2015 12:56 pm

Thanks Gaev and Dave,
That basically how I do it now.
The code was so similar I wondered how you got my code. :lol: :?:
Brian Robinson
'When all else fails, try again!'
www.ComputerSoftwareSystems.com
User avatar
BRobinsonS
 
Posts: 340
Joined: Sun Sep 25, 2005 9:00 pm
Location: Ontario, Canada


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 2 guests

cron