Sign in to follow this  
Followers 0
MikeS

FileMove Coding Problem

6 posts in this topic

Hello,

I having trouble getting this code to work. It copies a txt file into a *.log file using the Datetime stamp. I'm just learning Autoit scripting and can not find which line of code is not right. so to save time, I was need some to look over this code and see if anything stands out, and then I can try it and see if it will run correctly.

Thanks,

Mike

Dim $DateTime = @YEAR & "-" & @MON & "-" & @MDAY & "-" & @HOUR & "-" & @MIN & "_" & @SEC

Dim $Location = @WorkingDir & '\\new\\'

Dim $FileName = "all.txt"

FileMove($Location & $FileName , $Location & $DateTime & ".log",1)

sleep(4000)

Run(@ComSpec & ' /k "del ..\\Password\\new\\*.txt"', @ScriptDir, @SW_HIDE)

sleep(4000)

Share this post


Link to post
Share on other sites



Hello,

I having trouble getting this code to work. It copies a txt file into a *.log file using the Datetime stamp. I'm just learning Autoit scripting and can not find which line of code is not right. so to save time, I was need some to look over this code and see if anything stands out, and then I can try it and see if it will run correctly.

Thanks,

Mike

Dim $DateTime = @YEAR & "-" & @MON & "-" & @MDAY & "-" & @HOUR & "-" & @MIN & "_" & @SEC

Dim $Location = @WorkingDir & '\\new\\'

Dim $FileName = "all.txt"

FileMove($Location & $FileName , $Location & $DateTime & ".log",1)

sleep(4000)

Run(@ComSpec & ' /k "del ..\\Password\\new\\*.txt"', @ScriptDir, @SW_HIDE)

sleep(4000)

I really don't know what your trying to do here... Could explain step by step what you would like to see happen?

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

I really don't know what your trying to do here... Could explain step by step what you would like to see happen?

Step 1. copy all.txt file from workingDir to \\new

Step 2. move file to WorkingDir and rename it to DateTime.log

Step 3. Delete the all.txt file from WorkingDir

Hope this helps, As I did not invent this, the person that did is not around, so I need to put the pieces together.

Thanks, and if I can explain something in more detail or show you the complete script, I can do that. I just thought someone may see if the statements are even correctly written,

Mike

Share this post


Link to post
Share on other sites

You could try this:

Dim $DateTime = @YEAR & "-" & @MON & "-" & @MDAY & "-" & @HOUR & "-" & @MIN & "_" & @SEC
Dim $Location = @WorkingDir & '\new\'
Dim $FileName = "all.txt"

If FileExists($Location & $FileName) Then
    FileMove($Location & $FileName , $Location & $DateTime & ".log",1)
    Sleep(4000)
    If FileExists($Location & $FileName) Then FileDelete($Location & $FileName)
    Sleep(4000)
Else
    MsgBox(64, 'Info:', $Location & $FileName & ' Does not exist.')
EndIf


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Step 1. copy all.txt file from workingDir to \\new

Step 2. move file to WorkingDir and rename it to DateTime.log

Step 3. Delete the all.txt file from WorkingDir

Hope this helps, As I did not invent this, the person that did is not around, so I need to put the pieces together.

Thanks, and if I can explain something in more detail or show you the complete script, I can do that. I just thought someone may see if the statements are even correctly written,

Mike

The code SmOke_N gave you should work, yours appears to have been written in a context where the backslash "\" had to be escaped by another, giving "\\". That does not generate valid paths in AutoIT.

:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Thanks SmOke_N, it did worked great.

Thanks for taken time to help me with my FileMove problem.

Mike

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