Jump to content

inserting value of variable into cmd command


Recommended Posts

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
Link to comment
Share on other sites

I have not tried, but you should write your command like this:

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

Link to comment
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)

Link to comment
Share on other sites

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
Link to comment
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)
Link to comment
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.

Link to comment
Share on other sites

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