Sign in to follow this  
Followers 0
copyleft

Need help renaming a file

8 posts in this topic

Here's the broken code so far:

$Bak = (@YEAR & "-" & @MON & "-" & @MDAY)

If FileExists ("G:\IMAGE\TEST2.IMG" ) Then

FileMove("G:\Backup\" & $Bak)

Exit(0)

EndIf

Produces the error code:

"Incorrect number of parameters in function call."

Share this post


Link to post
Share on other sites



This one won't work either. (comma in the wrong place?)

$Bak = (@YEAR & "-" & @MON & "-" & @MDAY)

If FileExists ("G:\IMAGE\TEST2.IMG" ) Then

FileMove("G:\IMAGE\TEST2.IMG", "G:\Backup\" & $Bak)

Exit(0)

EndIf

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Are you sure that's exactly what you have? I made a little test with this code (tried to be exactly like yours):

$Bak = ( @YEAR & "-" & @MON & "-" & @MDAY )
If FileExists( "C:\name.txt" ) Then
FileMove( "C:\name.txt", "C:\" & $Bak )
Exit(0)
EndIf

and it works fine. Notice though (not that this is the problem) that you're cutting the extension off the name of the file, which may screw up any attempts to open it later.

Anyway try copying and pasting that, if it doesn't work, try reinstalling AutoIT.

Edited by dlp

Share this post


Link to post
Share on other sites

This one won't work either. (comma in the wrong place?)

$Bak = (@YEAR & "-" & @MON & "-" & @MDAY)

If FileExists ("G:\IMAGE\TEST2.IMG" ) Then

FileMove("G:\IMAGE\TEST2.IMG", "G:\Backup\" & $Bak)

Exit(0)

EndIf

and the question is ... What exactly does not work? Choose between:

  • the backup file gets the wrong name
  • the backup directory does not exist
  • I can't view the backup image with my preferred image viewer
  • my computer crashed
  • the whole internet crashed for 5 seconds when I started the script (sorry for that !!)
Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Check out my batch file renamer...written in AutoIT (source available as well)

Home: http://www.shrum.net/code/renamer

Binary: http://www.shrum.net/code/renamer/bin

Help : http://www.shrum.net/code/renamer/help

Source: http://www.shrum.net/code/renamer/source

Allows for a token-based name with date and time elements.

Edited by sshrum

Sean Shrum :: http://www.shrum.net

All my published AU3-based apps and utilities

'Make it idiot-proof, and someone will make a better idiot'

 

Share this post


Link to post
Share on other sites

I think you need the extension $Bak & ".IMG"

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I got this licked finally. The reason this worked for dlp and not me is because he wasn't renaming the file in a directory but in the root of his drive. The renaming will fail if you include a directory and don't create it (stupid me). Also, I had to put the extension in the $Bak declaration line not in the filemove line. So here's the working code for anyone that may find it useful: :P

$Bak1 = (@YEAR & "-" & @MON & "-" & @MDAY & "XP.IMG")
$Bak2 = (@YEAR & "-" & @MON & "-" & @MDAY & "2K.IMG")

If FileExists("D:\Image") Then
    MsgBox(65, "Imaging", "Standby While We Image Your Drives", 5)
Else
    DirCreate("D:\Image")
    MsgBox(65, "Imaging", "Standby While We Image Your Drives", 5)
EndIf
RunWait ("program.exe D:\IMAGE\TEST2.IMG")
WinWaitNotActive("Program Window Title")
RunWait ("program.exe D:\IMAGE\TEST1.IMG")
WinWaitNotActive("Program Window Title")

If FileExists ("D:\IMAGE\TEST2.IMG" ) Then
FileMove("D:\IMAGE\TEST2.IMG", "D:\Image\" & $Bak1)
; Exit(0)
EndIf
Sleep(1000)
If FileExists ("D:\IMAGE\TEST1.IMG" ) Then
FileMove("D:\IMAGE\TEST1.IMG", "D:\Image\" & $Bak2)
; Exit(0)
EndIf

; still can't figure out code to kill out renamed files older than 10 days so I call a visual basic substitute to kill them off
  
RunWait(@ComSpec & " /c " & 'delimg.vbs', "", @SW_HIDE)
Exit (0)
Edited by copyleft

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