Link to home
Start Free TrialLog in
Avatar of Mike Minchinton
Mike MinchintonFlag for United States of America

asked on

Need a script that will create its own directory to dump logs into

So I have this script below, and when it goes and retrieves logs, I need it to actually create its own directory in a folder in the C: drive.   I have attached the script.

Anybody have any ideas on how I can make it create a directory each log dump?


SCRIPT:
Echo OFF
Echo "Copy Flex Terminal Log files.  Press Any Key If You Think You Can Handle It"

:NO
SET /p FN=Enter Flex Name:
Echo You Entered - %FN%
@ECHO OFF

:choice
set /P c=Is this correct Flex Name(Y/N)?
if /I "%c%" EQU "Y" goto :yes
if /I "%c%" EQU "N" goto :NO
goto :choice
Pause

:yes
SET /p DATE=Enter Date(mm-dd-yyyy):
Echo You Entered - %DATE%
:choice
set /P c=Is this correct date(Y/N)?
if /I "%c%" EQU "Y" goto :RUN
if /I "%c%" EQU "N" goto :YES
goto :choice
Pause

:RUN
net use \\%FN% PASSWORD /user:DOMAIN\USERNAME

xcopy "\\%FN%\c$\CGTDeviceManager\Logs" "C:\Users\USERNAME\Desktop\ZIPS" /D:%DATE%
xcopy "\\%FN%\c$\Program Files\Primeline Enterprise\Applications" "C:\Users\USERNAME\Desktop\ZIPS" /D:%DATE%
***xcopy "\\%FN%\c$\Users\ser-flexuser\AppData\Roaming\FlexTerminalClient\Local Store" "C:\Users\USERNAME\Desktop\ZIPS" /D:%DATE%***
xcopy "\\%FN%\c$\Documents and Settings\ser-flexuser\Application Data\FlexTerminalClient\Local Store" "C:\Users\USERNAME\Desktop\ZIPS" /D:%DATE%

Pause

Open in new window

Avatar of Bill Prew
Bill Prew

Do you mean you want a new subfolder in C:\Users\USERNAME\Desktop\ZIPS?  If so, what do you want the name to be?

Don't use DATE as a variable name, that is a system defined variable that you shouldn't re-use, I changed it to DT for my example.  Below creates a dest folder of XXXXXX and then copies to that location.

Also, you know that for the current logged on user name you can reference the %USERNAME% variable, right?

@Echo OFF
setlocal

Echo "Copy Flex Terminal Log files.  Press Any Key If You Think You Can Handle It"

:NO
SET /p FN=Enter Flex Name:
Echo You Entered - %FN%
@ECHO OFF

:choice
set /P c=Is this correct Flex Name(Y/N)?
if /I "%c%" EQU "Y" goto :yes
if /I "%c%" EQU "N" goto :NO
goto :choice
Pause

:yes
SET /p DT=Enter Date(mm-dd-yyyy):
Echo You Entered - %DT%
:choice
set /P c=Is this correct date(Y/N)?
if /I "%c%" EQU "Y" goto :RUN
if /I "%c%" EQU "N" goto :YES
goto :choice
Pause

:RUN
net use \\%FN% PASSWORD /user:DOMAIN\USERNAME

set DestDir=C:\Users\USERNAME\Desktop\ZIPS\XXXXXX
md "%DestDir%"

xcopy "\\%FN%\c$\CGTDeviceManager\Logs" "%DestDir%" /D:%DT%
xcopy "\\%FN%\c$\Program Files\Primeline Enterprise\Applications" "%DestDir%" /D:%DT%
xcopy "\\%FN%\c$\Users\ser-flexuser\AppData\Roaming\FlexTerminalClient\Local Store" "%DestDir%" /D:%DT%***
xcopy "\\%FN%\c$\Documents and Settings\ser-flexuser\Application Data\FlexTerminalClient\Local Store" "%DestDir%" /D:%DT%

Pause

Open in new window

»bp
Avatar of Mike Minchinton

ASKER

Actually, I need the logs to dump into a folder on the C: drive named Source-Code.  Good idea on the DATE idea.
So just adjust this set to the folder you want:

set DestDir=C:\Users\USERNAME\Desktop\ZIPS\XXXXXX


»bp
Is it possible to have it create a new directory each time, and name it the terminal ID?
Where would "Terminal ID" come from?

And would it be unique every time you ran the script?


»bp
the terminal ID is the first thing you enter when the script runs, and its unique in the way that the logs are always different
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

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