Windows command prompt: escape special characters within quotation marks

I´d like to untar a tar.gz file with 7-Zip using this command:

forfiles /M *tar.gz /C "cmd /c "C:\Program Files\7-Zip\7z" e @path"

but I can´t make it work because of the whitespace within Program Files. How can I escape it?

Update:

My alternative solution is:

set 7ZPath="C:\Program Files\7-Zip\7z"
%7ZPath% e *.tar.gz

Upvotes: 0

Views: 2473

Answers (2)

dbenham
dbenham

Reputation: 130819

Quotes within your FORFILES command string must be escaped as \"

forfiles /M *tar.gz /C "cmd /c \"C:\Program Files\7-Zip\7z\" e @path"

Upvotes: 1

Abhineet
Abhineet

Reputation: 5389

forfiles /M *tar.gz /C "cmd /c "%ProgramFiles%\7-Zip\7z" e @path"

Upvotes: 1

Related Questions