Possible with a batch file? - Printable Version
-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: Possible with a batch file? (/showthread.php?tid=91547)
Possible with a batch file? by Jimbo on 07-18-2009 at 10:38 AM
Would this be possible to do with a batch file? or not?
What I would like to do is, say I had the folders: C:/folder1/folder2/ and inside folder 2 were many files, say "file1.ext, file2.ext2, file3.ext3" for now. Would it be possible for a batch file to list each file, and the path before it from folder2/ so the batch file would create a txt similar to:
folder2/file1.ext
folder2/file2.ext2
folder2/file3.ext3
Could then, the same batch file, or another, copy that lines from that .txt into the bottom of another .txt in another folder such as C:/stuff/list/default.lst (well, .lst, but same priniciple)
Could it then copy all those files that were listed and paste them recursively in another folder like C:/inetpub/wwwroot/folder1/folder2, but also, bzip2 those files in the inetpup folder??
Is that possible using a batch file? or not worth the effort?
RE: Possible with a batch file? by ShawnZ on 07-18-2009 at 12:00 PM
dir /s /b c:\inetpub
?
RE: Possible with a batch file? by Jimbo on 07-18-2009 at 01:07 PM
That would just list the files and store them as a list in C:/inetpub?
I would like to list the files, copy them into the bottom of another file, the copy all the files listed to inetpub/wwwroot/folder1/folder2 and bzip them.
RE: Possible with a batch file? by ShawnZ on 07-18-2009 at 01:47 PM
dir /s /b c:\inetpub >> c:\inetpub\someotherfile
then, err, get tar and bzip2 for windows...
why bzip anyway?
RE: Possible with a batch file? by Jimbo on 07-18-2009 at 02:22 PM
Running a few gameservers, and need an automated system to read the models and materials folders, add them to a downloadlist, bzip them, and add to a webserver running off the same box.
RE: Possible with a batch file? by ShawnZ on 07-18-2009 at 02:27 PM
why do you need a download list *and* an archive though? and why does it have to be bzip2 and not just zip/rar?
or is it just the file list itself that you need to bzip?
RE: Possible with a batch file? by Jimbo on 07-18-2009 at 02:56 PM
Well the download list is to force clients to download files, and the source engine cannot decompress any other archive than bz2, so, its best to bz2 all files, not the directory though, but each file individually. Bzip2 isnt necesarry, but speeds up download time immensly.
RE: Possible with a batch file? by CookieRevised on 07-20-2009 at 12:13 AM
Yes, it sure is all possible (in multiple ways)...
But I realy can't understand what you realy/exactly want to do though....
You need to give proper and very clear examples of each step if you want people to be able to create a batch file.
Are there any files listed in that "other .txt" which are not in 'folder2'?
Or is that "other txt" simply a list of all the files in 'folder2'?
Are there any files in 'folder1'?
Must the files in 'folder1' also be copied to 'C:/inetpub/wwwroot/folder1'?
Are there more subfolders 'folder3', 'folder4', etc under 'folder1'?
Are there other folders like 'folder1' under the C root and must they also be copied to 'c:\inetpub\wwwroot'?
BZip each file in 'folder2' to 'C:/inetpub' or to 'C:/inetpub/wwwroot/folder1/folder2'?
Give an extensive but exact BZip command line example, including the correct parameters, subpaths, quotes, filenames, etc so I can add it properly.
etc...
etc...
I am going to assume a lot of things here: batch code: @ECHO OFF
:: Be carefull, since Delayed Expansion is enabled, there will be errors if files contain "!" or other special characters in their path/file name.
:::::::::::::::::::::::::::::::::::::::::::::::
SET WWWDIR=C:\INETPUB\WWWROOT
SET LISTFILE=C:\STUFF\LIST\DEFAULT.LST
SET BZIPFILE=C:\UTILS\BZIP2.EXE
:::::::::::::::::::::::::::::::::::::::::::::::
VERIFY EXTTEST 2>NUL
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
IF ERRORLEVEL 1 GOTO NOEXTENSIONS
FOR /R %%F IN (*.*) DO (
IF NOT "%%F"=="%~0" (
SET FILE=%%F
ECHO Copying !FILE:%CD%\=!...
ECHO !FILE:%CD%\=! 2>NUL 3>&2 1>>%LISTFILE%
MD %WWWDIR%%%~pF 1>NUL 2>&1
COPY %%F %WWWDIR%%%~pF /Y 1>NUL 2>&1
ECHO Compressing !FILE:%CD%\=!...
%BZIPFILE% -fzkq9 "%WWWDIR%%%~pnxF"
)
)
ECHO.
ECHO "%LISTFILE%" updated
ECHO.
ECHO Press any key to end...
PAUSE 1>NUL
ECHO.
GOTO END
:NOEXTENSIONS
ECHO.
ECHO ERROR: Command extensions can not be enabled.
ECHO (possible cause: wrong DOS/Windows version)
GOTO END
:END
Also see attached batch file.
Edit the batch file (the three variables between the :::: lines) before using.
Put that batch file in each 'folder1' and run it from there.
It will also copy files under 'folder1', except itself.
It will bzip each file under C:/inetpub/wwwroot/folder1 without moving it to somewhere else (so you will have two versions of each file in each directory).
RE: Possible with a batch file? by Mike on 07-20-2009 at 12:34 AM
Or, you can just use SourceRSC which will do all the hard work for you (and even upload the compressed files to your server via FTP if you want)
RE: Possible with a batch file? by Jimbo on 07-24-2009 at 08:07 PM
Thanks for all that work Cookie, Its really appreciated, I will remember to provide a lot more clear examples in future. However, that program Mike supplied is far easier and more user-friendly. Thanks
RE: Possible with a batch file? by dimitrifrom31 on 08-07-2009 at 05:36 PM
Iam very interested in a this batch but I dont seem to be able to get it working so here is a description of what I would like it to do :
Lets say I got a folder called folder1 : C:\folder1
Inside folder1 i got a bunch of files I want to be synchronized with a second folder called folder2 : C:\folder2
Basically I want the files present in folder1 copied to folder2 but in a bzipped version.
Also I want the files present in C:\defaul.lst ignored by the process and defaul.lst updated at the end of the process with the recently copied files so they wont be copied again at next execution.
I tried your batch but its creating folders with weird names and not copying/compressing files, just folders.
I know only the very basis of batch so your help would be highly appreciated on this.
thx in advance if you can do anything
RE: Possible with a batch file? by dimitrifrom31 on 08-07-2009 at 08:26 PM
nvm dont waste time on this i purchased the paid version of RSC, does the job
RE: Possible with a batch file? by ShawnZ on 08-08-2009 at 12:42 AM
quote: Originally posted by dimitrifrom31
nvm dont waste time on this i purchased the paid version of RSC, does the job
there's a paid version?
RE: Possible with a batch file? by dimitrifrom31 on 08-08-2009 at 12:48 AM
ye for 30$ u can get it. Only difference is that you dotn have to push a key when process ended.
Im still trying to make a kind of batch now for HL games cuz I need to copy files from folder1 that are not listed in list.txt to folder2 without preserving the folders structure.
basically all the files but not the folders need to be dropped into folder2
I tried with xcopy but im having issues to get it working
RE: Possible with a batch file? by ShawnZ on 08-08-2009 at 12:49 AM
try "robocopy"
RE: Possible with a batch file? by dimitrifrom31 on 08-08-2009 at 01:34 AM
Well the problem is that I need the files dropped in the same folder.
Lets take an exemple :
D:\folder1\file1.txt
D:\folder1\folder2\file2.txt
I want them copied to
D:\folder3\file1.txt
D:\folder3\file2.txt
|