cmd file name with space between each string

  • Hi,

    I have a file which I named "file1 codp meta2.rar"

    As you can see this file name as spaces betwwen string which makes the below command don't work:

    set @NomeFinal ='file1 codp meta2.rar'

    set @DirectoriaFinal='c:'

    select @cmd = '"C:\Program Files\WinRAR\WinRAR.exe" x -u '+@NomeFinal+' '+@DirectoriaFinal+''

    exec master..xp_cmdshell @cmd, no_output

    The execute command only takes part of the name "file1" because of the spaces...

    How can I make this work ? the file name shoud have spaces....

  • try using double quotes around file name:

    set @NomeFinal ='"file1 codp meta2.rar"'

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • If I do that. then I have this (below) as the name of the file.

    It does not work too..

    c:\import\"PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar"

  • river1 (5/24/2012)


    If I do that. then I have this (below) as the name of the file.

    It does not work too..

    c:\import\"PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar"

    try

    "c:\import\PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar"

    MVDBA

  • is that the full query or is there more after the +'' at the end?

  • This is how the command tries to execute:

    "C:\Program Files\WinRAR\WinRAR.exe" x -u c:\import\"PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar" c:\import\"PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar"_Dir\

  • river1 (5/24/2012)


    This is how the command tries to execute:

    "C:\Program Files\WinRAR\WinRAR.exe" x -u c:\import\"PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar" c:\import\"PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar"_Dir\

    It's wrong. The whole path should be surrounded by double-quotes:

    ... -u "c:\import\PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar"

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • what is the full query, not the full command as looking at that command, you have missed a load of stuff from the query

    set @NomeFinal ='file1 codp meta2.rar'

    set @DirectoriaFinal='c:'

    select @cmd = '"C:\Program Files\WinRAR\WinRAR.exe" x -u '+@NomeFinal+' '+@DirectoriaFinal+''..............................................

    exec master..xp_cmdshell @cmd, no_output

  • full query (still don't work):

    set @nomeexacto = (select top 1 s from a1 where s like '%'+@nomeficheiro+'%')

    set @DirectoriaFinal = '"'+@caminho+@nomeexacto+'_Dir\"'

    set @NomeFinal='"'+@caminho+@nomeexacto+'"'

    set @cmd = 'mkdir '+@DirectoriaFinal

    exec master..xp_cmdshell @cmd, no_output

    select @cmd = '"C:\Program Files\WinRAR\WinRAR.exe" x -u '+@NomeFinal+' '+@DirectoriaFinal+''

    --select @cmd

    exec master..xp_cmdshell @cmd, no_output

    Result:

    "C:\Program Files\WinRAR\WinRAR.exe" x -u "c:\import\PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar" "c:\import\PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar_Dir\"

  • your command needs to look like

    C:\Program Files\WinRAR\WinRAR.exe x -u "c:\import\PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar" "c:\import\PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar_Dir\"

    MVDBA

  • From what I saw you just took the " from "C:\Program Files\WinRAR\WinRAR.exe"

    but Program Files as a space does it work?

  • It's as you told:

    C:\Program Files\WinRAR\WinRAR.exe x -u "c:\import\PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar" "c:\import\PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar_Dir\"

    Still does not work....

  • what errors do you get as I just run the following in a cmd prompt and it works fine

    "c:\program files\winrar\winrar.exe" x -u "c:\users\anthony.green\desktop\deadlock.rar" "c:\users\anthony.green\desktop\deadlock_rar\"

    Also run this with no errors

    "c:\program files\winrar\winrar.exe" x -u "c:\users\anthony.green\desktop\dead lock.rar" "c:\users\anthony.green\desktop\dead lock_rar\"

  • without you telling us the error message i can only assume you don't have winrar command line installed

    MVDBA

  • river1 (5/24/2012)


    It's as you told:

    C:\Program Files\WinRAR\WinRAR.exe x -u "c:\import\PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar" "c:\import\PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar_Dir\"

    Still does not work....

    Is

    PastaExportacao SGCTlocal - 4.01 - 20120523 112426 - T - 1118.rar_Dir

    a folder name?

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

Viewing 15 posts - 1 through 15 (of 26 total)

You must be logged in to reply to this topic. Login to reply