Unfortunately my knowledge on writing scripts is very basic so I'm wondering if someone can help me.
I've written a simple script that people can run to retreive the latest version of a file from the server which then goes on to copy it to their local workstation. Now what I've done works just fine but, a requirement for it to work is for them to already have the final destination folder created on their workstation.
What I've done so far:
echo off
cls
echo You are about to update your copy of test.accdb
echo
pause
copy s:\test\test.accdb c:\progra~1\test\test.accdb /Y
echo
echo Update installed.
echo
pause
What I want to add to the above is a way for the script to check if the folder exists. If it does, then I want it to go ahead with deploying the new version of the file as normal. If it doesn't, then I want the script to create the destination folder and then continue to copy in the new file.
Is this possible? And can anyone tell me what I need to do?
Cheers.
Feb-10-2009 15:15
whiskers
old skool
Registered: Sep 2001
Location: in your dreams
quick google search (i'm not proficient in batch programming):
check if directory exists: IF EXIST c:\windows\nul ECHO Directory exists!
create directory: md c:\newdir
I don't know how to do a "not" in batch programming, but if you say
IF [NOT] EXIST C:/yourdir md C:/yourdir
something like that.
___________________
Feb-10-2009 15:25
KiNeTiC ENeRgY
t3cHn0_43ad
Registered: Oct 2003
Location: Boca Raton
why don't u ask software code issues on a trance music site?
Feb-10-2009 15:28
whiskers
old skool
Registered: Sep 2001
Location: in your dreams
quote:
Originally posted by KiNeTiC ENeRgY
why don't u ask software code issues on a trance music site?
You must not have been paying attention. People who listen to EDM have higher IQs than the rest of the music lovers. People with higher IQs are good with computers. QED. You must be a lover of hip-hop.
___________________
Feb-10-2009 15:33
DJ Mikey Mike
Your mum's face
Registered: Jan 2002
Location: I'm at your mums'
I'll look into it whiskers, cheers.
quote:
Originally posted by KiNeTiC ENeRgY
why don't u ask software code issues on a trance music site?
Because there are quite a few users on here who, unlike yourself, aren't fucking useless little cunts and actually know their shit with this sort of thing. I've asked a handful of questions like this one in the past and have always gotten the answer I wanted.
Feb-10-2009 15:36
KiNeTiC ENeRgY
t3cHn0_43ad
Registered: Oct 2003
Location: Boca Raton
quote:
Originally posted by whiskers
You must not have been paying attention. People who listen to EDM have higher IQs than the rest of the music lovers. People with higher IQs are good with computers. QED. You must be a hip-hop lover.
false. Your logic skills suck. High IQ does not equal knowing code without prior knowledge, or anything else for that matter. I might seek out this information from a software coder site. A simple google search would get his answer.
Feb-10-2009 15:36
KiNeTiC ENeRgY
t3cHn0_43ad
Registered: Oct 2003
Location: Boca Raton
quote:
Originally posted by DJ Mikey Mike
I'll look into it whiskers, cheers.
Because there are quite a few users on here who, unlike yourself, aren't fucking useless little cunts and actually know their shit with this sort of thing. I've asked a handful of questions like this one in the past and have always gotten the answer I wanted.
Funny cause I know the answer, but since u are such a ****, I won't tell u.
Feb-10-2009 15:37
DJ Mikey Mike
Your mum's face
Registered: Jan 2002
Location: I'm at your mums'
Whatever you sad fuck I'm finishing work now. I know I'll have my answer by tomorrow, whether it be on here or on one of the other boards I've posted on. I always do.
Feb-10-2009 15:42
basd
progression
Registered: Jul 2002
Location: Somewhere nowhere
quote:
Originally posted by whiskers
quick google search (i'm not proficient in batch programming):
check if directory exists: IF EXIST c:\windows\nul ECHO Directory exists!
create directory: md c:\newdir
I don't know how to do a "not" in batch programming, but if you say
IF [NOT] EXIST C:/yourdir md C:/yourdir
something like that.
You're right.
Mike, just add the following statement to your batch file:
IF NOT EXIST [full dir path]\nul MD [full dir path]
The '\nul' part right behind the path is the DOS (Unix?) workaround for the EXIST command to check for folders to exist, since the EXIST command on itself works on files only. '\nul' is a file which will exist in all DOS directories by default, so to say.
Registered: May 2008
Location: The Pacific Northwest, of course
quote:
Originally posted by KiNeTiC ENeRgY
why don't u ask software code issues on a trance music site?
i believe that is what he is doing...
man dos/windows batch scripts are fugly...
Feb-11-2009 06:54
DJ Mikey Mike
Your mum's face
Registered: Jan 2002
Location: I'm at your mums'
quote:
Originally posted by basd
You're right.
Mike, just add the following statement to your batch file:
IF NOT EXIST [full dir path]\nul MD [full dir path]
The '\nul' part right behind the path is the DOS (Unix?) workaround for the EXIST command to check for folders to exist, since the EXIST command on itself works on files only. '\nul' is a file which will exist in all DOS directories by default, so to say.