Search : in
By :

Open a file with spaces from batch file?

Last answer on Dec 14, 2008 6:50:09 am GMT Branflakes91093, on Jul 27, 2008 7:46:47 pm BST 
 Report this message to moderators

Hello,
I have made a batch file that will ask you what file name you want to open and what directory it's in.
The only problem is that i can't open files with spaces in the name because it treats the first word as the whole file.
Can someone help me?
Here's the code:

cls
@echo off
:CD
cls
echo Change directory?
echo.
set /p "cho=>"
if %cho%==y goto Change
if %cho%==Y goto Change
if %cho%==n goto Open
if %cho%==N goto Open
cls
echo That's not a valid choice, dumbass.
pause
goto CD
:Open
cls
echo What would you like to open? (Name and Extension) Or type "End" to exit.
echo.
set /p "n=>"
if %n%==End goto End
if %n%==end goto End
if %n%=="End" goto End
if %n%=="end" goto End
start %n%
goto Open
goto End
:Change
cls
echo Enter the desired directory.
echo.
set /p "x=>"
CHDIR %x%
goto Open
:end

Placing quotes around the input variables opens up another cmd window for some reason...
Thanks.

Configuration: Windows XP
Internet Explorer 7.0

Best answers for « Open a file with spaces from batch file? » in :
Renaming multiple files in batch Show Renaming multiple files in batch Native features Using a third-party program Renaming a large number of files can quickly become tedious. Fortunately, there are tools to automate this task in many cases: Native features On Windows...
How to open file .ps (Postscript) ShowHow to open file .ps (Postscript) INTRO Using PDF Creator Using Ghostview INTRO PostScript (PS) is a page programming language used for desktop publishing. Below is a small tips on how to open .ps file. Using PDF...
Create and Open a RAR file ShowCreate and Open a RAR file *How to create a RAR file *How to open a RAR file RAR is an archive file format that is used during data compression, error recovery and file spanning. RAR is the acronym for Roshal Archive, inspired by...
Opening a PPS FILE ShowOpening a PPS FILE PPS, acronym for PowerPoint Show, is a tool created by Microsoft Office PowerPoint for distinguished presentations and slideshows. PowerPoint enables you to draft your own presentation within different display and design...
Download SWF Opener ShowSWF Opener is a reader allowing to read videos in format Flash (extension SWF) stocked in the hard disk, for instance in the temporary files of the browser. He allows to read videos in flash without Internet Explorer, possibly in full screen and...
File formats and extensions ShowWhat is a MIME type? The MIME type (Multipurpose Internet Mail Extensions) is a standard that was proposed by the Bell Communications laboratories in 1991 to broaden the possibilities of email, involving insertion of documents (images, sounds and...

1

Branflakes91093, on Jul 28, 2008 1:08:41 am BST
  • +17

BTW have vista 32 bit

Reply to Branflakes91093

2

haydster7, on Oct 19, 2008 9:23:33 am BST
  • +8

Surround file name with double quotes

Reply to haydster7

3

 anonymous, on Dec 14, 2008 6:50:09 am GMT
  • +4

Short & Sweet Answer. Thanks. Shrawan.

Reply to anonymous