1.

Solve : BATCH FILE HELP PLEASE (IF EXIST COMMAND)?

Answer»

I want to check to see if a user dir exists, if it does, I want to move the contents to another (mapped) drive. here is what I wrote

@echo off
if not exists %SYSTEMDRIVE%\documents and settings\%username%\local settings\application data\microsoft\outlook GOTO :end

rem else

cd %SYSTEMDRIVE%\documents and settings\%username%\local settings\application data\microsoft\outlook
copy *.* U:\outlook_Backup

:end


I've tried variations of this code and nothing seems to work. it ignores my if exists or if not exists... I heard that this command only checks for files and not folders as I originally thought, but I've tried this too. I assume it's something simple- help PLEASE!


TRY this with the NUL keyword and some WELL placed quotes.

Code: [Select]
@echo off
if not exists "%SYSTEMDRIVE%\documents and settings\%username%\local settings\application\data\microsoft\outlook\nul" goto :end

rem else

cd %SYSTEMDRIVE%\documents and settings\%username%\local settings\application data\microsoft\outlook
copy *.* U:\outlook_Backup

:end


Simple enough? Thank you for this help.. STILL not working.

I tried it and got ... "was unexpected at this time" from the command line prompt..




@echo off

if not exists "%SYSTEMDRIVE%\documents and settings\%username%\local settings\application data\microsoft\outlook\nul" goto :end

cd %SYSTEMDRIVE%\documents and settings\%username%\local settings\application data\microsoft\outlook
copy *.* U:\outlook_Backup

:end
Use both quotes and EXIST not EXISTS and forget about the NULL. I should have caught that earlier. :-/

Code: [Select]
@echo off
if not exist "%SYSTEMDRIVE%\documents and settings\%username%\local settings\application data\microsoft\outlook" goto :end

cd %SYSTEMDRIVE%\documents and settings\%username%\local settings\application data\microsoft\outlook
copy *.* U:\outlook_Backup

:end



Hope this is more better.



Discussion

No Comment Found