Jump to content
Sign in to follow this  
inthewayboy

Create File Name Based On Date

Recommended Posts

inthewayboy

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!

Share this post


Link to post
Share on other sites
inthewayboy

Oh, I forgot to ask this. How would I reference the file name in the next part of the script, as it would be changing every day. Meaning, after the file is compressed and named, how will I tell the FTP upload part of the script which file to upload. Thanx!

Share this post


Link to post
Share on other sites
Valuater

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

Share this post


Link to post
Share on other sites
AutoChris

#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"

Share this post


Link to post
Share on other sites
Valuater

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

Share this post


Link to post
Share on other sites
inthewayboy

Hey, thanx for all the info...I agree, it is smarter to use yyyy.mm.dd so that things are easier to find. I will keep that in mind. I'll test the suggestions later on today...got a few emergencies to handle first!

Share this post


Link to post
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
Sign in to follow this  

×