Sign in to follow this  
Followers 0
jbsoccerbrit

inserting value of variable into cmd command

9 posts in this topic

#1 ·  Posted (edited)

I know the below is not correct but hopefully it gives the general idea of what I am wanting to do.

RunWait(@COMSPEC & " /cd $location rename *.$fileextension *.$newextensionname")

so in the command window it would perform a CD command to change current dir (press enter)

the pull in the vars for the current extension and the extension to be renamed to.

Edited by jbsoccerbrit

Share this post


Link to post
Share on other sites



C:\Documents and Settings\****\Desktop\test.au3(62,1) : ERROR: syntax error

(

^

C:\Documents and Settings\****\Desktop\test.au3(62,82) : ERROR: syntax error

(@COMSPEC & " /cd " & $someText2 & " rename *." & $someText1 & " *." & $someText3)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\****\Desktop\test.au3 - 2 error(s), 0 warning(s)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

RunWait(@COMSPEC & ' /c ' & 'rename "' & $location & "*." & $fileextension & '"' & " *." & $newextensionname, "",@SW_HIDE)

[edit] This one I've tested! If you have spaces in the directory name, you have to enclose that: "bla bla" or 'bla bla'

Edited by taietel

Share this post


Link to post
Share on other sites

Is there anyway to make the location change first so its cd $location and then the rename folders suit?

I.E

CD $location

rename *.ext1 *.ext2

Otherwise I dont think it will work thank you kindly for the help :idea:

Share this post


Link to post
Share on other sites

Here is another working example (change it to your needs):

$location = "tempx"
$fileextension = "chm"
$newextensionname = "mih"
RunWait(@COMSPEC & ' /c ' & 'cd "' & $location & '"',"",@SW_HIDE)
RunWait(@COMSPEC & " /c " & "rename *." & $fileextension & " *." & $newextensionname, $location,@SW_HIDE)

Share this post


Link to post
Share on other sites

unfortunately the two runwaits would have to be merged into one line otherwise once the CD (Change Directory) is done and closes the rename isn't applied to anything.

I've tried filemove and it just seems to delete the file... at a loss with this.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

 I've merged it in one line (I've tested it - working!):

RunWait(@COMSPEC & " /c " & "cd '" & $location & "' & rename *." & $fileextension & " *." & $newextensionname, $location,@SW_HIDE)

[edit] Why did you use filemove?

Edited by taietel

Share this post


Link to post
Share on other sites

It was a suggestion from someone else to try, based on them recalling that autoit didn't have its own rename feature. Thanks again for all the help :idea:

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