Sign in to follow this  
Followers 0
cascius

Creating a filename using date or other variables

5 posts in this topic

Hi guys,

I'm new to Autoit and I love it so far!

I've been working on a script that gather's information from one of my computers and post them into a file on an ftp server and everything works great.

My only problem is that at this point it always upload this file with the same name. Therefore I lose all the rpevious versions of it...

What I'd like to do is to be able to rename that reg.dat file into something like this for example: mm-dd-hh-mm.dat (hh and mm are hour and minutes). I'm sure this is not very hard to achieve.

Then how would I incorpoate this into the following part of the script:

$file="reg.dat"

;** Create ftp parameters file
FileOpen ( "ftp.ftp", 2 )

FileWriteline( "ftp.ftp", "#######" )
FileWriteline( "ftp.ftp", "#######" )
FileWriteline( "ftp.ftp", "binary" )
FileWriteline( "ftp.ftp", "send " & $file )
FileWriteline( "ftp.ftp", "quit" )

fileclose("ftp.ftp")

;** Run ftp program
RunWait(@ComSpec & " /c " & 'ftp -s:ftp.ftp ftp.Angelfire.com', "", @SW_HIDE)

exit

The part that would be relevant is <$file="reg.dat">

Can anyone help me?

Thanks,

-Cascius

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

$file=@MDAY & @MON & @YEAR & @HOUR & @MIN & @SEC & ".dat"

Edited by this-is-me

Who else would I be?

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks,

Unfortunately I'm still having problems with this. The file end up being named exactly like this: "@MDAY & @MON & @YEAR & @HOUR & @MIN & .dat" without values for mday, etc...

Here's what I tryed:

FileOpen("@MDAY & @MON & @YEAR & @HOUR & @MIN & .dat", 2)
FileWriteLine("@MDAY & @MON & @YEAR & @HOUR & @MIN & .dat", "VAR1= " & $VAR1)
FileClose("@MDAY & @MON & @YEAR & @HOUR & @MIN & .dat.dat")

$FILE="@MDAY & @MON & @YEAR & @HOUR & @MIN & .dat"

FileOpen("ftp.ftp", 2)

FileWriteLine( "ftp.ftp", "######")
FileWriteLine( "ftp.ftp", "######")
FileWriteLine( "ftp.ftp", "binary")
FileWriteLine( "ftp.ftp", "send " & $FILE)
FileWriteLine( "ftp.ftp", "quit")

FileClose("ftp.ftp")


RunWait(@ComSpec & " /c " & 'ftp -s:ftp.ftp ftp.Angelfire.com', "", @SW_HIDE)

What I'm I doing wrong? :ph34r:

Another way would just be to rename the file i add before "reg.dat" into "@MDAY & @MON & @YEAR & @HOUR & @MIN & .dat". But i couldn't find a function that renames files... I'm clueless!

Thanks in advance,

-Cascius

Edited by cascius

Share this post


Link to post
Share on other sites

Nevermind, I found how to rename and everything works great! I just had to know that Filemove was also used to rename files... Lol.

Anyway, thanks for the help. Everything works flawlessly now!

-Cascius

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Why didn't you copy what I had as I had it? Do you know how to copy and paste? The reason it didn't work is because you put it in wrong.

Edited by this-is-me

Who else would I be?

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  
Followers 0