Link to home
Start Free TrialLog in
Avatar of Hector7869
Hector7869Flag for United States of America

asked on

Batch Script to find out if a folder exists

I am trying to make a simple batch script for windows to find out if a user's folder exists on share on a server. If the folder does not exist, I want it to create one with the user's username. Here is what I have so far.

if not exist \\server\\sharedfolder\%username% md \\server\sharedfolder\%username%

Basically I want to run this as a log on script so a each user can have their own folder on a server, some already have one, so that is why I need to check to see if they have one or not.
ASKER CERTIFIED SOLUTION
Avatar of Shift-3
Shift-3
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Hector7869

ASKER


Thats what I thought, for some odd reason it will not make a new folder in my script. If I isolate it and put in a sperate batch file it works, but in my overall script is does not. Here is what the whole batch file looks like. It should check the folder existence first and then create one if it is not there. Then map that folder on the computer.

if not exist \\server4\archive\%username% md \\server4\archive\%username%
 

net use i: \\server2\activefile /user:domain\%username%
net use j: \\server2\archfile /user:domain\%username%
net use t: \\server1\team /user:domain\%username%
net use m: \\server3\users$\%username% /user:domain\%username%
net use l: \\server4\Archive\%username% /user:domain\%username%
 
Hmm... I don't know what happened but now it works, I did reset the permission on the shared folder, so mabey that was it. Thanks