Advertisement

01.22.2008 at 03:04PM PST, ID: 23102912
[x]
Attachment Details

Space in path breaks bat file - workaround?

Asked by deanc1983 in MS DOS, Windows XP Operating System, Windows Batch Scripting

Tags: Microsoft, Windows/DOS, bat file

I'm trying to write a batch file that is launched via the command prompt. The file will launch the batch file which copies files from one destination to another, It will look something like
C:\test.bat "C:\source files" C:\destination

I realize that because there is a space in the filepath ,"" must be placed around it for the batch file to execute. I am looking for a workaround to this, or something to be written behind the scenes so that if a user has a filepath containing spaces and inputs their filepath with the spaces but with no quotes the batch file will still execute. Please help!!!!!!!!

Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
set batchDest=%2\%username%
set appsDir=%2\APPS\
md %batchDest%\LOG
rem --------------------------------------------------
rem    robocopy commands
rem      /COPY:DAT copy files with D=data, A=attributes, T=timestamps
rem      /E        copy subdirectories, including empty directories
rem      /R:1      retry 1 time on a failed copy
rem      /W:15     wait 15 seconds before retrying the copy
rem      /TS       include source file timestamps in the OUTPUT
rem      /FP       include full path of files in the OUTPUT
rem      /LOG+:    output status to a LOG file, appending to an existing file
rem      /TEE      output to console window as well as a LOG file
rem --------------------------------------------------
%appsDir%robocopy.exe %1 %batchDest%\DATA * /COPY:DAT /E /R:1 /W:15 /TS /FP /LOG+:"%batchDest%\LOG\%username%_robocopyLog.txt" /TEE
[+][-]01.22.2008 at 05:10PM PST, ID: 20720036

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: MS DOS, Windows XP Operating System, Windows Batch Scripting
Tags: Microsoft, Windows/DOS, bat file
Sign Up Now!
Solution Provided By: SteveGTR
Participating Experts: 1
Solution Grade: A
 
 
[+][-]01.22.2008 at 05:52PM PST, ID: 20720278

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.22.2008 at 09:46PM PST, ID: 20721075

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.23.2008 at 07:26AM PST, ID: 20724012

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.14.2008 at 06:10AM PDT, ID: 21563710

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]05.23.2008 at 05:25PM PDT, ID: 21636947

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628