Sign in to follow this  
Followers 0
mohan93

Please help me in Renaming a file and extension

5 posts in this topic

Hi Everyone, 

I have 2 queries, please assist,

1. Rename a file:

I have a file in C:TempGLW123.tmp 

I need to rename the file to Setup.wse  and the file should be placed in the same directory C:temp

2. Embedding a .VBS file within the autoScript complied EXE.

i can achieve the above renaming functionality  using below VBS. 

SearchFileName = "GLW123.tmp"               
RenameFileTo   = "SETUP.WSE"
For each file In folder1.Files    
    'WScript.Echo (file.Name)
    If instr(file.name, searchFileName) = 1 Then
         file.name = renameFileTo
           Exit For
    End If
Next
 
is there any option to embed this VBS inside the EXE and use the VBS in my autoit script.
 
Please Help.
 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi, mohan93. Why bother using the vbs at all? Check the help file for more info on _FileListToArray.

#include <File.au3>
#include <Array.au3>

Local $aArray = _FileListToArray("C:\Temp", "*", 1)

    For $i = 1 To $aArray[0]
        If $aArray[$i] = "GLW123.tmp" Then FileMove("C:\Temp\GLW123.tmp", "C:\Temp\SETUP.WSE", 1)
    Next
Edited by JLogan3o13
1 person likes this

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

 

Hi, mohan93. Why bother using the vbs at all? Check the help file for more info on _FileListToArray.

#include <File.au3>
#include <Array.au3>

Local $aArray = _FileListToArray("C:\Temp", "*", 1)

    For $i = 1 To $aArray[0]
        If $aArray[$i] = "GLW123.tmp" Then FileMove("C:\Temp\GLW123.tmp", "C:\Temp\SETUP.WSE", 1)
    Next

Uhm, why are you using _FileListToArray() at all? That doesn't make much sense to me.

Just FileMove() it.

1 person likes this

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Awesome, Thanks JLogan3o13 and Queen F. Elizabeth MCXI :)

Share this post


Link to post
Share on other sites

Trancexx, I only did so because the OP showed that he was doing a search in the vbs in his OP. It appeared he was searching the directory to see if the file exists, and then moving. Otherwise you are of course correct, I would have simply done a FileMove.


√-1 2^3 ∑ π, and it was delicious!

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