Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm thinking if does exist some kind of software that can put in a queue a bunch of windows commands. For example I can say to first copy some file somewhere, then rename those, then delete the old files, then edit one of them etc. without waiting the effective execution of any of those passages. This could be useful when copying big files that take a lot and I don't want to sit in front of the computer keeping the eyes on the progress bar.

Does anything like this exist?

share|improve this question
add comment

2 Answers

easiest thing to do is to write a batch file for what you want do, for example open notepad and copy the following:

@echo off
echo Starting batch script
copy c:\temp\*.* c:\temp2\*.*
del c:\temp2\test.exe
echo all file operations complete

Next, save this somewhere as anything .bat and you can run it either by double clicking, or going to the command prompt and typing its name. All operatings you write in it will get processed in order.

share|improve this answer
    
yes i know this solution, but it's a bit frustrating to write down paths everytime... this functionality should be integrated wihtin windows, but they are too lazy :( –  Stefano Nov 5 '09 at 23:16
2  
So... you're looking for a program that "knows" where you want to copy files and which ones you might want to edit? How about in Wil's example change the paths with variables: copy %1% %2% ?? –  DaveParillo Nov 5 '09 at 23:35
    
What about tasks that normally don't use commands? For example drag and drop task, or context menu tasks. I'd love to have 7zip wait for previous extract to finish before starting a new extraction. –  syockit Jan 18 '11 at 17:11
    
@syockit - used the 7zip command line version, extract to a temporary directory, do the operations on that etc. There is nearly always a way to use the command line for anything! –  William Hilsum Jan 18 '11 at 18:11
3  
@Syockit - you can actually modify a .bat whilst it is running, and if it hasn't reached that line yet, it will run the new command... E.g. if I write "echo test, pause" and during the pause, I modify to "echo test, pause, echo blabla"... when I press enter, I will actually see blabla. –  William Hilsum Mar 1 '11 at 18:18
show 3 more comments

I wrote this little batch script some time ago called QSTART. Maybe it will help.

It allows you (in theory) to create and execute queues of any BATCH commands. Queues are plain text files stored in %TEMP% directory.

It's a very simple script I use i.e. to queue zip commands when doing backups.

I didn't do much debugging, therefor feel free to correct any existing bugs. I'm not 100% sure if it handles properly every BATCH command string, but it should suit for simple tasks.

Important. Every queued command is executed exactly as it is. The script doesn't check for any errors, but simple ERRORLEVEL validation inside the FOR loop can fix that.

Also I'm not a professional programmer and am aware that the script is a bit messy (ie. I didn't know any other way to run queued command; the built-in START command sometimes doesn't work for me).

There is help and some examples at the end of the script. Use QSTART without arguments to display it.

@echo OFF
setlocal

rem qstart root directory
set ROOT=%~dp0
call :DEBUG "qstart root directory: %ROOT%"

rem queue storage directory
set QDIR=%TMP%
call :DEBUG "queue directory: %QDIR%"

rem 1.parameter (mandatory) - queue ID
rem if no queue ID given display help message
set QID=%~1
call :DEBUG "queue ID: %QID%"
if "%QID%"=="" goto :MSG_HELP
set QFILE=%QDIR%\%QID%.Q
call :DEBUG "queue file: %QFILE%"
shift

rem 2. parameter (mandatory) - queue operation
set QOP=%~1
shift
call :DEBUG "queue operator: %QOP%"

if "%QOP%"=="add" goto :QADD
if "%QOP%"=="list" goto :QLIST
if "%QOP%"=="load" goto :QLOAD
if "%QOP%"=="new" goto :QNEW
if "%QOP%"=="remove" goto :QREMOVE
if "%QOP%"=="run" goto :QRUN
if "%QOP%"=="save" goto :QSAVE
goto :ERR_SYNTAX

rem add command to queue
rem create queue if not exists
:QADD
    if not exist "%QFILE%" call :QNEW
    set QCMD=:
    :NEXTPAR
        set QCMD=%QCMD% %1
        shift
        if not "%~1"=="" goto :NEXTPAR
    set QCMD=%QCMD:: =%
    call :DEBUG "queued command: %QCMD%"
    echo %QCMD% >>"%QFILE%"
    goto :EOF

rem list queued commands
rem warn if queue not exists
:QLIST
if not exist "%QFILE%" (
    call :ERR_BADQID
) else (
    type "%QFILE%"
)
goto :EOF

rem import queue from file
rem create queue if not exists
rem warn if file not exists
:QLOAD
    if not exist "%QFILE%" call :QNEW
    set FILE=%~1
    call :DEBUG "load file: %FILE%"
    if not exist "%FILE%" (
        call :ERR_NOFILE
    ) else (
        copy /B /Y "%QFILE%"+"%FILE%" "%QFILE%" >NUL
    )
    goto :EOF

rem clear queue
rem create queue if not exists
:QNEW
    if exist "%QFILE%" call :QREMOVE
    copy /B /Y NUL "%QFILE%" >NUL
    goto :EOF

rem remove queue
rem warn if queue not exists
:QREMOVE
    if not exist "%QFILE%" (
        call :ERR_BADQID
    ) else (
        del /F /Q "%QFILE%" >NUL
    )
    goto :EOF

rem execute queued commands
rem clear queue after execution
:QRUN
    if not exist "%QFILE%" (
        call :ERR_BADQID
    ) else (
        setlocal ENABLEDELAYEDEXPANSION
        for /F "tokens=* delims=" %%C in (%QFILE%) do (

            %%C
            rem alt.way of execution: start "" /B /WAIT %%C

            call :DEBUG "ERROR LEVEL of last operation: !ERRORLEVEL!"
        )
        endlocal
        rem call :QREMOVE
        call :QREMOVE
    )
    goto :EOF

rem export queue to file
rem warn if queue not exists
rem overwrite file if exists
:QSAVE
    set FILE=%~1
    call :DEBUG "save file: %FILE%"
    if not exist "%QFILE%" (
        call :ERR_BADQID
    ) else (
        copy /B /Y "%QFILE%" "%FILE%" >NUL
    )
    goto :EOF


rem messages ------------------------------------------------------------------

rem bad syntax error
rem show help
:ERR_SYNTAX
    echo ERROR: syntax error
    call :MSG_HELP
    goto :EOF

rem bad queue id error
:ERR_BADQID
    echo ERROR: bad queue ID '%QID%'
    goto :EOF

rem file not found error
:ERR_BADFILE
    echo ERROR: file not found '%FILE%'
    goto :EOF

rem usage information
:MSG_HELP
    echo qstart v.0.1.5 - by rapia19@interia.pl
    echo Allows to create and execute queues of BATCH commands.
    echo.
    echo USAGE: qstart {QUEUE_ID} {QUEUE_OPERATOR} {COMMAND or FILE}
    echo        qstart {-h^|--help^|?^|/?}
    echo   {QUEUE_ID}          queue ID
    echo   {QUEUE_OPERATOR}    queue operator
    echo   {COMMAND}           queued command call
    echo   {FILE}              import/export filename
    echo   -h --help ? or /?   shows ^(this^) help message
    echo Allowed operations:
    echo   add {COMMAND}   adds command to the queue
    echo   list            lists all queued commands
    echo   load {FILE}     imports ^(appends^) queued commands from a file
    echo   new             creates new or clears existing queue
    echo   remove          deletes queue
    echo   run             executes all queued command and deletes queue
    echo   save {FILE}     exports queue to a file
    echo ALSO:
    echo   set QDEBUG=1    turns on displaying debug messages
    echo EXAMPLES:
    echo   qstart Hello add echo "Hello world!"
    echo   qstart Hello add pause
    echo   qstart Hello list
    echo   qstart Hello save Hello-copy.txt
    echo   qstart Hello new
    echo   qstart Hello load Hello-copy.txt
    echo   qstart run
    pause
    goto :EOF

rem display debug message and pause
:DEBUG
    if "%QDEBUG%"=="1" (
        echo ### DEBUG INFO ### %~1
        pause >NUL
    )
    goto :EOF
share|improve this answer
    
Ahum, "little" batch script? Nice! –  Arjan Feb 8 at 12:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.