Jump to content

Creating a filename using date or other variables


cascius
 Share

Recommended Posts

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

Link to comment
Share on other sites

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