Jump to content

dos commands


Guest colinw64
 Share

Recommended Posts

Guest colinw64

I am a novice at using autoit. I am trying to produce a very simple (or so I thought!!) script, to carry out a few simple DOS commands. I originally used autoit to call a bath file to perform these commands, but decided to attempt to do everything from within an autoit script. These commands will involve renaming a directory, copying a number of files over from a cd to c:\ drive, and removing read only attrib's from the copied files, plus a few other operations.

I am having great difficulties in achieving even the simplest operation of renaming a directory.

I have tried a number of different command lines, with various syntax settings, all derived from the command given within the help files for autoit, namely

"Run, COMMAND.COM /C Echo Hello > C:\\Hello.txt", which seems to be the basic syntax for running DOS commands.

(I have, of course, been substituting the 2nd part of the command line with the DOS "rename" command, plus the relevant directory, I am trying to rename, etc)

I have tried too many variations on this to list them all here, so I'd be grateful if someone could point me in the direction of what the command line should be for renaming a directory on the c:\ drive to be another name.

The DOS command that I am using within the batch file to do this, is

'rename c:\climate climate_backup', and this works fine from within the batch file, but i cannot seem to get this to work directly from within the autoit script!!

Link to comment
Share on other sites

Run, %COMSPEC% ren c:\climate climate_backup,, Max

//Correction: that's not working for directories, only for files - sorry was a quick NoBrainer :D

-----

If you have to stay backward compatible with AutoIt 2 check if AutoHotkey will solve your issue. It provides a new, more advanced FileMoveDir command (AutoIt 3 provides it as well, but IMHO AHK in most cases is less complex to understand)

FileMoveDir, C:\My Folder, C:\My Folder (renamed), 1

FileMoveDir

Running AutoIt2 (.aut) Scripts

Edited by Beastmaster
Link to comment
Share on other sites

I am a novice at using autoit. I am trying to produce a very simple (or so I thought!!) script, to carry out a few simple DOS commands. I originally used autoit to call a bath file to perform these commands, but decided to attempt to do everything from within an autoit script. These commands will involve renaming a directory, copying a number of files over from a cd to c:\ drive, and removing read only attrib's from the copied files, plus a few other operations.

I am having great difficulties in achieving even the simplest operation of renaming a directory.

I have tried a number of different command lines, with various syntax settings, all derived from the command given within the help files for autoit, namely

"Run, COMMAND.COM /C Echo Hello > C:\\Hello.txt", which seems to be the basic syntax for running DOS commands.

(I have, of course, been substituting the 2nd part of the command line with the DOS "rename" command, plus the relevant directory, I am trying to rename, etc)

I have tried too many variations on this to list them all here, so I'd be grateful if someone could point me in the direction of what the command line should be for renaming a directory on the c:\ drive to be another name.

The DOS command that I am using within the batch file to do this, is

'rename c:\climate climate_backup', and this works fine from within the batch file, but i cannot seem to get this to work directly from within the autoit script!!

look up dircopy, dirmove and FileGetAttrib

You don't need to use dos for that stuff

Rick

Link to comment
Share on other sites

Guest colinw64

Unfortunately, I could not get the

'Run, %COMSPEC% ren c:\climate climate_backup,, Max'

to function correctly either, but I didn't spend too much time looking into the reasons for this, as I found the link to AutoHotKey very useful, and have now managed to satisfy all my requirements using AHK.

Thanks for your replies...I'm a happy bunny now

Happy Scripting

:D

Link to comment
Share on other sites

Moves files and renames files and directories

To move one or more files:

MOVE [/Y | /-Y] [drive:][path]filename1[,...] destination

To rename a directory:

MOVE [/Y | /-Y] [drive:][path]dirname1 dirname2

[drive:][path]filename1 Specifies the location and name of the file

or files you want to move.

destination Specifies the new location of the file. Destination

can consist of a drive letter and colon, a

directory name, or a combination. If you are moving

only one file, you can also include a filename if

you want to rename the file when you move it.

[drive:][path]dirname1 Specifies the directory you want to rename.

dirname2 Specifies the new name of the directory.

/Y Suppresses prompting to confirm you want to

overwrite an existing destination file.

/-Y Causes prompting to confirm you want to overwrite

an existing destination file.

The switch /Y may be present in the COPYCMD environment variable.

This may be overridden with /-Y on the command line. Default is

to prompt on overwrites unless MOVE command is being executed from

within a batch script.

-----

Run, %COMSPEC%  /C /Y Move c:\\climate climate_backup,, Hide

That should work with AutoIt 2 to rename a directory. :D
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...