:COPYDIR :: If this dir contains DBs, copy the files to the JK Update Data folder. :: Else copy all files in this dir to the hard disk. echo ====== Directory %4 set DOCROOT=%3 if '%4'=='"%CDDBDIR%"' goto :COPYDB1 if '%4'=='"_install"' goto :EOF xcopy %CDDRIVE%\%4\* %3 /r /e %DATEFLAG% /f /i /s /h /y cd %~P0 goto :EOF :COPYDB1 for /D %%D in (%DATAROOT%\*) do %~F0 _copydb2 "%%D" cd %~P0 goto :EOF :COPYDB2 for /F %%F in (%2\*) do %~F0 _copydb3 "%%F" %%~nxF cd %~P0 goto :EOF :COPYDB3 if exist %CDDRIVE%\%CDDBDIR%\%3 xcopy %CDDRIVE%\%CDDBDIR%\%3 %2 /r /e %DATEFLAG% /f /i /s /h /y cd %~P0 goto :EOF
Batch file - Unable to get databases to copy to correct file locationUnable to get databases to copy to correct file location
Page 1 of 1
11 Replies - 1159 Views - Last Post: 10 November 2008 - 07:42 AM
#1
Batch file - Unable to get databases to copy to correct file location
Posted 05 November 2008 - 07:02 AM
Replies To: Batch file - Unable to get databases to copy to correct file location
#2
Re: Batch file - Unable to get databases to copy to correct file location
Posted 05 November 2008 - 07:14 AM
@echo off
set CDDRIVE=%~D0
set ROOTFILE=%CDDRIVE%\_root.txt
set CDDBDIR=_db
set DATADIR="\Program Files\jkupdate\data\db\tm"
:: Check for command extensions before we start.
if cmdextversion 1 (echo.) else goto :NOCMDEXT
if '%1'=='' goto START
if '%1'=='/d' goto STARTDATE
if '%1'=='_copydir' goto COPYDIR
if '%1'=='_copydb2' goto COPYDB2
if '%1'=='_copydb3' goto COPYDB3
:: Print usage message and bail out.
echo Usage: %0 [/d]
goto :EOF
:STARTDATE
set DATEFLAG=/d
:START
:: Check for existence of the root file.
if not exist %ROOTFILE% goto :NOROOTFILE
:: Get the root folder name from the root file.
cd %CDDRIVE%\
for /F "delims=:" %%f in ('type %ROOTFILE%') do set ROOTDIR=%%f
:: Determine the destination directory for the data.
title Install JTDI Updates
echo Ready to begin install of JTDI updates.
pause
if '%CDDRIVE%'=='F:' goto SKIPF1
set HDDRIVE=f:
set DOCROOT=f:%ROOTDIR%
if exist %DOCROOT% goto SETDATAROOT
:: 2007-02-06:sc: JTDI 1.0 sites will be <drive>:\JTDI\<service>. Adding check so that this install will work with both structures.
set DOCROOT=f:\JTDI%ROOTDIR%
if exist %DOCROOT% goto SETDATAROOT
:SKIPF1
if '%CDDRIVE%'=='E:' goto SKIPE1
set HDDRIVE=e:
set DOCROOT=e:%ROOTDIR%
if exist %DOCROOT% goto SETDATAROOT
:: 2007-02-06:sc: JTDI 1.0 sites will be <drive>:\JTDI\<service>. Adding check so that this install will work with both structures.
set DOCROOT=e:\JTDI%ROOTDIR%
if exist %DOCROOT% goto SETDATAROOT
:SKIPE1
if '%CDDRIVE%'=='D:' goto SKIPD1
set HDDRIVE=d:
set DOCROOT=d:%ROOTDIR%
if exist %DOCROOT% goto SETDATAROOT
:: 2007-02-06:sc: JTDI 1.0 sites will be <drive>:\JTDI\<service>. Adding check so that this install will work with both structures.
set DOCROOT=d:\JTDI%ROOTDIR%
if exist %DOCROOT% goto SETDATAROOT
:SKIPD1
if '%CDDRIVE%'=='C:' goto SKIPC1
set HDDRIVE=c:
set DOCROOT=c:%ROOTDIR%
if exist %DOCROOT% goto SETDATAROOT
:: 2007-02-06:sc: JTDI 1.0 sites will be <drive>:\JTDI\<service>. Adding check so that this install will work with both structures.
set DOCROOT=c:\JTDI%ROOTDIR%
if exist %DOCROOT% goto SETDATAROOT
:SKIPC1
echo Could not find %ROOTDIR% nor \JTDI%ROOTDIR% directories on hard disk. Exiting.
pause
goto :EOF
:SETDATAROOT
if '%CDDRIVE%'=='F:' goto SKIPF2
set DATAROOT=f:%DATADIR%
if exist %DATAROOT% goto GENLIST
:SKIPF2
if '%CDDRIVE%'=='E:' goto SKIPE2
set DATAROOT=e:%DATADIR%
if exist %DATAROOT% goto GENLIST
:SKIPE2
if '%CDDRIVE%'=='D:' goto SKIPD2
set DATAROOT=d:%DATADIR%
if exist %DATAROOT% goto GENLIST
:SKIPD2
if '%CDDRIVE%'=='C:' goto SKIPC2
set DATAROOT=c:%DATADIR%
if exist %DATAROOT% goto GENLIST
:SKIPC2
set DATAROOT=''
:GENLIST
:: Generate a list of top-level dirs and reinvoke the program once for each dir.
cd %CDDRIVE%\
for /D %%D in (*) do %~F0 _copydir %HDDRIVE% %DOCROOT% "%%D" %DATAROOT%
cd %~P0
goto :EOF
:COPYDIR
:: If this dir contains DBs, copy the files to the JK Update Data folder.
:: Else copy all files in this dir to the hard disk.
echo ====== Directory %4
set DOCROOT=%3
if '%4'=='"%CDDBDIR%"' goto :COPYDB1
if '%4'=='"_install"' goto :EOF
xcopy %CDDRIVE%\%4\* %3 /r /e %DATEFLAG% /f /i /s /h /y
cd %~P0
goto :EOF
:COPYDB1
for /D %%D in (%DATAROOT%\*) do %~F0 _copydb2 "%%D"
cd %~P0
goto :EOF
:COPYDB2
for /F %%F in (%2\*) do %~F0 _copydb3 "%%F" %%~nxF
cd %~P0
goto :EOF
:COPYDB3
if exist %CDDRIVE%\%CDDBDIR%\%3 xcopy %CDDRIVE%\%CDDBDIR%\%3 %2 /r /e %DATEFLAG% /f /i /s /h /y
cd %~P0
goto :EOF
:NOCMDEXT
echo.
echo Command extensions not enabled. Exiting.
pause
goto :EOF
:NOROOTFILE
echo Root file "%ROOTFILE%" not found. Exiting.
pause
goto :EOF
MOD EDIT: Please
Thanks, gabehabe
This post has been edited by gabehabe: 05 November 2008 - 08:54 AM
#3
Re: Batch file - Unable to get databases to copy to correct file location
Posted 05 November 2008 - 08:38 AM
Also, please
Haha, it spells fishy:
/f /i /s /h /y
Anyway, what's your database like? Is it a single file? A collection of files? Does it span across just one directory, or does it go into subdirectories, too?
#4
Re: Batch file - Unable to get databases to copy to correct file location
Posted 05 November 2008 - 08:54 AM
Threads merged.
#5
Re: Batch file - Unable to get databases to copy to correct file location
Posted 05 November 2008 - 08:58 AM
gabehabe, on 5 Nov, 2008 - 07:38 AM, said:
Also, please
Haha, it spells fishy:
/f /i /s /h /y
Anyway, what's your database like? Is it a single file? A collection of files? Does it span across just one directory, or does it go into subdirectories, too?
They are individual fies. Usually 1-2 databases. They should pull from a CD in a subdirectory. I posted twice. My second post includes the whole code.
gabehabe, on 5 Nov, 2008 - 07:54 AM, said:
Threads merged.
Sorry. I didn't think the first post went through.
#6
Re: Batch file - Unable to get databases to copy to correct file location
Posted 05 November 2008 - 09:49 AM
Let me know if this isn't what you're looking for, like I said, I have't read over all your code:
REM Figure out which drive is the disc drive, I'll use E in my example SET CDDRIVE=E: XCOPY /e /v /y %CDDRIVE% "C:\Program Files\jkupdate\data\db\tm"
That will copy everything from your disc drive (drive E in my example) to C:\Program Files\jkupdate\data\db\tm, which is where you said you want it.
#7
Re: Batch file - Unable to get databases to copy to correct file location
Posted 05 November 2008 - 10:04 AM
gabehabe, on 5 Nov, 2008 - 08:49 AM, said:
Let me know if this isn't what you're looking for, like I said, I have't read over all your code:
REM Figure out which drive is the disc drive, I'll use E in my example SET CDDRIVE=E: XCOPY /e /v /y %CDDRIVE% "C:\Program Files\jkupdate\data\db\tm"
That will copy everything from your disc drive (drive E in my example) to C:\Program Files\jkupdate\data\db\tm, which is where you said you want it.
GREAT! Would I need to delete any of the code to make it work. Please see how I have inserted it.
:COPYDIR :: If this dir contains DBs, copy the files to the JK Update Data folder. :: Else copy all files in this dir to the hard disk. echo ====== Directory %4 set DOCROOT=%3 SET CDDRIVE=E: if '%4'=='"%CDDBDIR%"' goto :COPYDB1 if '%4'=='"_install"' goto :EOF xcopy %CDDRIVE%\%4\* %3 /r /e %DATEFLAG% /f /i /s /h /y cd %~P0 goto :EOF :COPYDB1 for /D %%D in (%DATAROOT%\*) do %~F0 _copydb2 "%%D" cd %~P0 goto :EOF :COPYDB2 for /F %%F in (%2\*) do %~F0 _copydb3 "%%F" %%~nxF cd %~P0 goto :EOF :COPYDB3 if exist %CDDRIVE%\%CDDBDIR%\%3 XCOPY /e /v /y %CDDRIVE% "C:\Program Files\jkupdate\data\db\tm" %2 /r /e %DATEFLAG% /f /i /s /h /y cd %~P0 goto :EOF
Thanks for your help.
#8
Re: Batch file - Unable to get databases to copy to correct file location
Posted 05 November 2008 - 11:30 AM
The best way to make sure it works is just to test it.
#9
Re: Batch file - Unable to get databases to copy to correct file location
Posted 05 November 2008 - 02:08 PM
gabehabe, on 5 Nov, 2008 - 10:30 AM, said:
The best way to make sure it works is just to test it.
I will test it out tomorrow. Thanks again for everything.
#10
Re: Batch file - Unable to get databases to copy to correct file location
Posted 06 November 2008 - 07:02 AM
knockkneed81, on 5 Nov, 2008 - 01:08 PM, said:
gabehabe, on 5 Nov, 2008 - 10:30 AM, said:
The best way to make sure it works is just to test it.
I will test it out tomorrow. Thanks again for everything.
Unfortunately it is still copying to the incorrect location. I need only the database to copy to the following destination C:Program Files\jkupdate\data\db\tm. The stuff in red are the modifications I made.
@echo off
set CDDRIVE=%~D0
set ROOTFILE=%CDDRIVE%\_root.txt
set CDDBDIR=_db
[color=#FF0000]set DATADIR="C:\Program Files\jkupdate\data\db\tm"[/color]
:: Check for command extensions before we start.
if cmdextversion 1 (echo.) else goto :NOCMDEXT
if '%1'=='' goto START
if '%1'=='/d' goto STARTDATE
if '%1'=='_copydir' goto COPYDIR
if '%1'=='_copydb2' goto COPYDB2
if '%1'=='_copydb3' goto COPYDB3
:: Print usage message and bail out.
echo Usage: %0 [/d]
goto :EOF
:STARTDATE
set DATEFLAG=/d
:START
:: Check for existence of the root file.
if not exist %ROOTFILE% goto :NOROOTFILE
:: Get the root folder name from the root file.
cd %CDDRIVE%\
for /F "delims=:" %%f in ('type %ROOTFILE%') do set ROOTDIR=%%f
:: Determine the destination directory for the data.
title Install JTDI Updates
echo Ready to begin install of JTDI updates.
pause
if '%CDDRIVE%'=='F:' goto SKIPF1
set HDDRIVE=f:
set DOCROOT=f:%ROOTDIR%
if exist %DOCROOT% goto SETDATAROOT
:: 2007-02-06:sc: JTDI 1.0 sites will be <drive>:\JTDI\<service>. Adding check so that this install will work with both structures.
set DOCROOT=f:\JTDI%ROOTDIR%
if exist %DOCROOT% goto SETDATAROOT
:SKIPF1
if '%CDDRIVE%'=='E:' goto SKIPE1
set HDDRIVE=e:
set DOCROOT=e:%ROOTDIR%
if exist %DOCROOT% goto SETDATAROOT
:: 2007-02-06:sc: JTDI 1.0 sites will be <drive>:\JTDI\<service>. Adding check so that this install will work with both structures.
set DOCROOT=e:\JTDI%ROOTDIR%
if exist %DOCROOT% goto SETDATAROOT
:SKIPE1
if '%CDDRIVE%'=='D:' goto SKIPD1
set HDDRIVE=d:
set DOCROOT=d:%ROOTDIR%
if exist %DOCROOT% goto SETDATAROOT
:: 2007-02-06:sc: JTDI 1.0 sites will be <drive>:\JTDI\<service>. Adding check so that this install will work with both structures.
set DOCROOT=d:\JTDI%ROOTDIR%
if exist %DOCROOT% goto SETDATAROOT
:SKIPD1
if '%CDDRIVE%'=='C:' goto SKIPC1
set HDDRIVE=c:
set DOCROOT=c:%ROOTDIR%
if exist %DOCROOT% goto SETDATAROOT
:: 2007-02-06:sc: JTDI 1.0 sites will be <drive>:\JTDI\<service>. Adding check so that this install will work with both structures.
set DOCROOT=c:\JTDI%ROOTDIR%
if exist %DOCROOT% goto SETDATAROOT
:SKIPC1
echo Could not find %ROOTDIR% nor \JTDI%ROOTDIR% directories on hard disk. Exiting.
pause
goto :EOF
:SETDATAROOT
if '%CDDRIVE%'=='F:' goto SKIPF2
set DATAROOT=f:%DATADIR%
if exist %DATAROOT% goto GENLIST
:SKIPF2
if '%CDDRIVE%'=='E:' goto SKIPE2
set DATAROOT=e:%DATADIR%
if exist %DATAROOT% goto GENLIST
:SKIPE2
if '%CDDRIVE%'=='D:' goto SKIPD2
set DATAROOT=d:%DATADIR%
if exist %DATAROOT% goto GENLIST
:SKIPD2
if '%CDDRIVE%'=='C:' goto SKIPC2
set DATAROOT=c:%DATADIR%
if exist %DATAROOT% goto GENLIST
:SKIPC2
set DATAROOT=''
:GENLIST
:: Generate a list of top-level dirs and reinvoke the program once for each dir.
cd %CDDRIVE%\
for /D %%D in (*) do %~F0 _copydir %HDDRIVE% %DOCROOT% "%%D" %DATAROOT%
cd %~P0
goto :EOF
:COPYDIR
:: If this dir contains DBs, copy the files to the JK Update Data folder.
:: Else copy all files in this dir to the hard disk.
echo ====== Directory %4
set [color=#FF0000]DATADIR=%3[/color]
if '%4'=='"%CDDBDIR%"' goto :COPYDB1
if '%4'=='"_install"' goto :EOF
xcopy %CDDRIVE%\%4\* %3 /r /e %DATEFLAG% /f /i /s /h /y
cd %~P0
goto :EOF
:COPYDB1
for /D %%D in (%DATAROOT%\*) do %~F0 _copydb2 "%%D"
cd %~P0
goto :EOF
:COPYDB2
for %%F in (%2\*) do %~F0 _copydb3 "%%F" %%~nxF
cd %~P0
goto :EOF
:COPYDB3
if exist %CDDRIVE%\%CDDBDIR%\%3 xcopy %CDDRIVE%\%CDDBDIR%\%3 [color=#FF0000]C:\%DATADIR%[/color] /r /e %DATEFLAG% /f /i /s /h /y
cd %~P0
goto :EOF
:NOCMDEXT
echo.
echo Command extensions not enabled. Exiting.
pause
goto :EOF
:NOROOTFILE
echo Root file "%ROOTFILE%" not found. Exiting.
pause
goto :EOF
This post has been edited by knockkneed81: 06 November 2008 - 07:05 AM
#11
Re: Batch file - Unable to get databases to copy to correct file location
Posted 10 November 2008 - 07:34 AM
gabehabe, on 5 Nov, 2008 - 10:30 AM, said:
The best way to make sure it works is just to test it.
Hello
Hello
#12
Re: Batch file - Unable to get databases to copy to correct file location
Posted 10 November 2008 - 07:42 AM
Tell me the structure of these discs~ Like I said, I can't test it.
Is it just the databases on the disc?
Example:
E:
--DB1
--DB2
Are they in subdirectories?
E:
--DB1
----DB1part1
----DB1part2
--DB2
Or are there additional files on the disc, as well as the databases?
|
|

New Topic/Question
Reply





MultiQuote







|