Batch File Help - Check, Move, Rename

Soldato
Joined
25 Oct 2009
Posts
6,706
Location
Caerphilly
I've got the following Batch file that checks for the existence of a certain file and if it exists moves it to a folder, and renames it. If it doesnt exist it moves it to that location and renames it.

The batch file works for the latter but the former doesnt. Keeps telling me incorrect syntax.

Code:
If exist C:\SDS.exe MOVE C:\SDS.exe "C:\PROGRAM FILES\SOLUS3\DEPLOYMENTSERVERUI\" REN "C:\PROGRAM FILES\SOLUS3\DEPLOYMENTSERVERUI\SDS.exe" "C:\PROGRAM FILES\SOLUS3\DEPLOYMENTSERVERUI\Sims.Solus3.DeploymentServer.UI.exe" ELSE
MOVE "C:\PROGRAM FILES\SOLUS3\DEPLOYMENTSERVERUI\Sims.Solus3.DeploymentServer.UI.exe" C:\ 
CD C:\
REN Sims.Solus3.DeploymentServer.UI.exe SDS.exe
ECHO Solus removed
PAUSE
EXIT

It's the first line thats the problem, if the file is there. Any ideas please?
 
Sorted.
Fixed with the following:
Code:
[FONT=Arial][SIZE=2][FONT=Arial]cd  c:\[/FONT][/SIZE][/FONT]
 [FONT=Arial][SIZE=2][FONT=Arial]if not exist SDS.exe  goto end else[/FONT][/SIZE][/FONT]
 [FONT=Arial][SIZE=2][FONT=Arial]MOVE C:\SDS.exe  "C:\PROGRAM FILES\SOLUS3\DEPLOYMENTSERVERUI\"[/FONT][/SIZE][/FONT]
 [FONT=Arial][SIZE=2][FONT=Arial]REN "C:\PROGRAM  FILES\SOLUS3\DEPLOYMENTSERVERUI\SDS.exe"  "Sims.Solus3.DeploymentServer.UI.exe"[/FONT][/SIZE][/FONT]
 [FONT=Arial][SIZE=2][FONT=Arial]EXIT[/FONT][/SIZE][/FONT]
 
 [FONT=Arial][SIZE=2][FONT=Arial]:end[/FONT][/SIZE][/FONT]
 [FONT=Arial][SIZE=2][FONT=Arial]MOVE "C:\PROGRAM  FILES\SOLUS3\DEPLOYMENTSERVERUI\Sims.Solus3.DeploymentServer.UI.exe" C:\  [/FONT][/SIZE][/FONT]
 [FONT=Arial][SIZE=2][FONT=Arial]CD  C:\[/FONT][/SIZE][/FONT]
 [FONT=Arial][SIZE=2][FONT=Arial]REN  Sims.Solus3.DeploymentServer.UI.exe SDS.exe[/FONT][/SIZE][/FONT]
 [FONT=Arial][SIZE=2][FONT=Arial]ECHO Solus  removed[/FONT][/SIZE][/FONT]
 [FONT=Arial][SIZE=2][FONT=Arial]PAUSE[/FONT][/SIZE][/FONT]
 [FONT=Arial][SIZE=2][FONT=Arial]EXIT[/FONT][/SIZE][/FONT]
 
Back
Top Bottom