Jump to content

Create File Name Based On Date


Recommended Posts

Okay, so this is my first time posting here, and I apologize in advance. I've tried searching the forums, but all the keyword I use seem to be too generic to get a direct hit. So I'm bringing it to you all :whistle:

I'm building a script that will be used to compress and then upload various files to an offsite FTP. I found an FTP script on the forums that does the upload portion very well. I've got a batch file that currently calls 7zip to compress my files. I would like to combine the both into one script. That I have no problem doing. But the compressing portion is getting to me.

What I would like is for the script to call 7zip and then use the current date as the filename...here is the command line I use in my batch file:

7za.exe a -t7z -mx=9 quickbooks.7z -i@files.txt

I have the 7za.exe in my System32 folder, so the path won't be an issue. The files that are compressed are contained in the files.txt, but that can be taken out if it's a problem.

So my questions are:

1. How would I integrate that command line into my script...is it as simple as:

RunWait ( "7za.exe a -t7z -mx=9 quickbooks.7z -i@files.txt" )

I just tried it and it looks like it will work, but can anyone advise on a problem they see with that?

2. I would like to replace "quickbooks.7z" with a variable that would equal the days date like this: 09.02.2005.7z

I see there are ways to define the date format and all that, but that goes a little beyond what small scripting skills I have aquired lately. I'm willing to do all the nasty trial and error, but I have no clue as to what to focus on.

Thanx again!

Link to comment
Share on other sites

RunWait ( "7za.exe a -t7z -mx=9 quickbooks.7z -i@files.txt" )

I just tried it and it looks like it will work, but can anyone advise on a problem they see with that?

2. I would like to replace "quickbooks.7z" with a variable that would equal the days date like this: 09.02.2005.7z

<{POST_SNAPBACK}>

#1

I don't see a problem, as long as it works in your test, it should be ok

#2

Dim $variable ; place this at the top of your script

$variable = @mday & "." & @mon & "." & @year & ".7z"

RunWait ( "7za.exe a -t7z -mx=9 " & $variable & " -i@files.txt" )

However,

you may need to rename the file first ( using the variable name) before you can use runWait.

??? this i don't know... not enough info here??

also later in the program use $variable to recall the name of the file you wish to up-load.

hope that helps

8)

NEWHeader1.png

Link to comment
Share on other sites

#1

I don't see a problem, as long as it works in your test, it should be ok

#2

Dim $variable ; place this at the top of your script

$variable = @mday & "." &  @mon & "." &  @year & ".7z"

RunWait ( "7za.exe a -t7z -mx=9 " & $variable & " -i@files.txt" )

However,

you may need to rename the file first ( using the variable name) before you can use runWait.

??? this i don't know... not enough info here??

also later in the program use $variable to recall the name of the file you wish to up-load.

hope that helps

8)

<{POST_SNAPBACK}>

Slight variation... He probably wants the date in American format (month.day.year) Otherwise, Valuator has it dead on.

$variable = @mon & "." &  @mday & "." &  @year & ".7z"
Link to comment
Share on other sites

Slight variation... He probably wants the date in American format (month.day.year) Otherwise, Valuator has it dead on.

$variable = @mon & "." &  @mday & "." &  @year & ".7z"

<{POST_SNAPBACK}>

Nice catch SerialKiller....

as a note all of my files are year.month.day I learned this years ago, it helps in searching what year i am looking for or what month in that year and ...

even if you do not know the day... they list very well

mine

20050831

20050901

20050902

20050903

others

31082005

01092005

02092005

03092005

imagine which is easier to sort/search/control

just a thought

8)

Edited by Valuater

NEWHeader1.png

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...