Frage

This is my code and it always seems to think that %filePath% exists, when I assume you it does not. No P:\Production\Database_backup\02182014-Database0400.mdb at all. My desktop is just for the testing before this gets used on he production DB

set "PublishDest=P:\Production\Database_backup\"
set source=C:\Users\kevin\Desktop\Database0400.md*
:Main

set "currDate=%date:~4,2%%date:~7,2%%date:~10,4%"
Set "fileName=%currDate%-Database0400.mdb"
Set "filePath=%PublishDest%%fileName%"

if exist %filePath% (
    ECHO %filePath%
    ECHO you made it in here!
    PAUSE
    ::IF prev backup on same day, increment all old backups and move current to first old
    call:IncrementArchives
    Echo.
)
War es hilfreich?

Lösung

When I turned @echo on so I could see exactly what I was running, I saw that I was asking

IF EXIST P:\Production\Database_backup\02182014-Database0400.mdb

Hmm I thought, would perhaps some Quotations help? So I typed it in the first time (instead of using the variable)

IF EXIST "P:\Production\Database_backup\02182014-Database0400.mdb"

Worked like a charm!

So, I replaced if exist %filePath% ( with if exist "%filePath%" ( and suddenly there were angels all around singing their beautiful song

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top