
Phaedrus
MemberContent Type
Profiles
Forums
Events
Everything posted by Phaedrus
-
DOS Batch File
Phaedrus replied to Phaedrus's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Yzöwl, after seeing you solve this problem, how can I possibly take offense to you calling me a newbie? In comparison, I certainly am. Nevertheless, Wise Owl is certainly an appropriate name for you. LOL. In any case, your advice is duly noted and appreciated, and I will do my best to follow forum rules and conventions. I've been out of circulation for 12 years, and have much catching up to do; with Internet forums, batch files, and Visual Basic 4.0, much has changed. I certainly appreciate your patience and interest in helping me. Thanks again. -
DOS Batch File
Phaedrus replied to Phaedrus's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Wise Owl, THANKS That one works perfectly !!! Consider this problem solved. Its exactly what I needed. I am running the z.bat file from inside a bin directory located in the path statement. Further, its an elegant solution. Yet I don't have the slightest clue how it works, LOL. But its perfect. Now I will need to spend many hours figuring out why it functions. I would never have figured this one out. Thanks again. -
DOS Batch File
Phaedrus replied to Phaedrus's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Well that tells me something which I would have ascertained earlier had you provide a response to jaclaz when asked in post number 11. r It appears that you may not have variable expansion working, try this: In your console window launch a new window using this commandSTART CMD /E:ON In that window use the example I've provided, (Do not omit the "%~f1\*" from the end). Then let us know what happens. Wise Owl, Many Thanks. I used this command with the /E:ON switch. Interesting that I must start a dos prompt to open a second dos prompt to do this as Norton Commander launch just shows bad filename. Nevertheless, this compresses the entire drive, and still does not pass the current directoryname to the archive filename I need. -
DOS Batch File
Phaedrus replied to Phaedrus's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
when I run RARMe.cmd from a dos box with nothing else specified from a directory 3 levels deep: 1) Compresses the entire hard drive instead of the current directory. 2) Places the compressed file in the root of the drive instead of the current directory. 3) Has no filename in front of the .rar extension instead of the "directoryname.rar". when I run RARMe_2.cmd from a dos box with nothing else specified from a directory 3 levels deep: 1) Compresses the entire hard drive instead of the current directory. 2) Places the compressed file in my C:\BIN directory instead of in the current directory. 3) Has no filename in front of the .rar extension instead of the "directoryname.rar". when I run RARMe_3.cmd from a dos box with nothing else specified from a directory 3 levels deep: 1) Compresses the entire hard drive instead of the current directory. 2) Places the compressed file properly of the current directory!!! 3) Has no filename in front of the .rar extension instead of the "directoryname.rar". Part of the problem may be that I want to type one character (z) for z.bat without specifying any other parameter, and have it automatically determine the current directory name without the entire path, then pass that name to RAR so that it archives the files as directoryname.rar inside that directory. Again, thanks for your efforts on my behalf. -
DOS Batch File
Phaedrus replied to Phaedrus's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
jaclaz, I just need the archive.rar filename to match the current directory name from a dos box. For example, in a dos box with z.bat as the batch file name and C:\dir1\dir2\directory contents.one as the current directory, I want to type z and press enter and have all the files in that directory compressed into a file named "directory contents.one.rar" for storage with the uncompressed files deleted. Notice that the -dr switch deletes the uncompressed files to recycle bin. I am using WinXP. Thanks for the info that my autoexec.bat is useless. However, I seem to be successfully using it to add my C:\BIN directory into the path which seems to be created somewhere else. First, I have no idea how or why my batch file works as it does, I'm totally unfamiliar with batch files in the recent operating systems. The batch file I'm using does that in all respects except for cases where a .Dot appears in the current directory name. I would like to fix this problem if possible. It seems to me that such a batch file would be quite useful to many people and I'm surprised that a simple google search does not turn one up. I followed your suggestion and looked at the Clevertricks website, but it was either over my head, or I did not see what I needed. You asked me "What happens in your batch with %~nx1 ?" The answer is, I'm not sure, but it needs to be there. Given the current batch file as follows, let me step through what I see happening line by line: ========================== begin z.bat ============================================ Call :FOLDER "%CD%" EXIT :FOLDER Set MyCurDir=%~n1 "C:\Program Files\WinRAR\RAR.exe" a -m5 -av -r -t -dr "%MyCurDir%.rar" ====================== end z.bat ================================================== Line one (Call :FOLDER "%CD%")is required, or else my resulting archive file has no name in front of the .rar extension. Line two (EXIT)is needed so that the whole compression routine does not duplicate itself and re-compress the files a second time. This effect mystifies me. Line three (:FOLDER) is obvious as where to go. Line four (Set MyCurDir=%~n1) is required, or else my resulting archive file has no name in front of the .rar extension. Line five ("C:\Program Files\WinRAR\RAR.exe" a -m5 -av -r -t -dr "%MyCurDir%.rar") , I tried deleting line four and instead replacing "%MyCurDir%.rar" with "%~n1.rar", but it just results in an archive file with no name in front of the extension. Sorry I cannot answer your questions better, but it is through my ignorance that I'm not giving you the information you need. Thanks for your efforts. -
DOS Batch File
Phaedrus replied to Phaedrus's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Wise Owl. If I use this portion of your code; @"%ProgramFiles%\WinRAR\rar" a -r -ep1 "%~nx1.rar" it archives the files in the correct directory, and places the archived file in that same directory, just as I desire. The only problem is that the resulting compressed archive filename is .rar with no prefix before the extension. I need the batch file to read the current directory name together with any spaces and dots in that directory name, and name the .rar file so that it matches the directory name, with the .rar extension. -
DOS Batch File
Phaedrus replied to Phaedrus's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Wise Owl. You have several good points. You are correct that I did not drag and drop. I'm still stuck in the long-gone past. I am executing my batch files either from a C: prompt in a dos box or from the old Norton Commander/Total Commander environment which handles everything via keystroke rather than mouse drag&drop. I was not aware that drag&drop functioned differently than DOS box execution . Wow, I'm getting too old. The fact is I never use Windows Explorer as it is much to slow for extensive file management when compared to Norton Commander or Total Commander, and am not very familiar with it. It did not even occur to me to use it when you suggested drag and drop. In any case, I need to execute the batch file from a Dos window or from Norton Commander. Do you have any suggestions? Hope I did not offend you by not specifying this sooner, I just did not realize the changes that have occurred with time. -
DOS Batch File
Phaedrus replied to Phaedrus's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Wise Owl, Did not mean to ignore you. The solution you proposed (@"%ProgramFiles%\WinRAR\rar" a -r -ep1 "%~dp0%~nx1.rar" "%~f1\*")compresses the entire hard drive. I only want it to compress the files contained in the current directory I am in. I tried several variations and cannot make it work. I need the resulting archived filename to match the current directory and support extended directory names, spaces in directory names, and .dots in directory names. The Archived file must end up in that same current directory. BTW, the -dr switch I use deletes all uncompressed files to the recycle bin after being archived, which I desire. Any suggestions? Thanks -
DOS Batch File
Phaedrus replied to Phaedrus's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
jaclaz , You are quite correct that it fails to work where a .Dot appears in the directory name. Let me try to elaborate on what I wish to accomplish - I want a batch file that is able to compress all the files in a directory with the resulting archive name being the same as the directory name which contains it. I chose rar instead of zip because of the support for extended file names within the archived file. No need exists to specify the files to compress because I want all *.* files to be added to the archive. The script I am using now accomplishes nearly everything, particularly in that it supports directory name spaces, but it still does not support a .Dot in the directory name as you wisely informed me. Can you please advise as to a solution? ========================= Begin z.bat ====================================================== Call :FOLDER "%CD%" EXIT :FOLDER Set MyCurDir=%~n1 "C:\Program Files\WinRAR\RAR.exe" a -m5 -av -r -t -dr "%MyCurDir%.rar" ======================== End z.bat ========================================================= Sorry I cannot answer your question as to what "%CD%" does or how the value is set. I do not know. I really do not understand how this batch file works. I have not written batch files since DOS 5.0 days and find that I have forgotten nearly everything. This batch file is placed in my C:\Bin directory and that directory is specified in the path statement of the autoexec.bat file. I also do not understand how the effect of my current file will change depending on the directory structure I'm in, it seems to work ok here with the exception of .Dots in the directory names. Thanks for your help -
DOS Batch File
Phaedrus replied to Phaedrus's topic in Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
Thanks jaclaz, However that did not seem to work for me. Nevertheless I was able to figure out a solution, though I'm sure it is not the most efficient or elegant. Here is my solution. I'm not real good at this. Can it be improved on? Thanks again. ============================================= REM Command Line Version Call :FOLDER "%CD%" EXIT :FOLDER Set MyCurDir=%~n1 "C:\Program Files\WinRAR\RAR.exe" a -m5 -av -r -t -dr "%MyCurDir%.rar" =============================================== -
I would like to compress the contents of my current folder using a batch file, have the archive name be set to the current folder name, and place the archived file in the current folder. I am now using the following script, however it places the archived file in the folder below, rather than in the current folder. Can someone correct my script please? "C:\Program Files\WinRAR\RAR.exe" a "%cd%.rar" Thank You