View Full Version : I need help creating a batch file
I hardly ever use DOS and have never made a batch file. I can understand the basic commands of rem, set, echo, if, etc, but once it gets into the % and such I start getting confused.
I want to make a batch file that runs winrtvcc then comskip or the following command:
cscript //nologo "c:\program files\videoredoPlus\AdScan.vbs" "<video file.mpg>" "<filename.vprj>" then delete the original file.
Winrtvcc will be in the same directory as the mpeg and automatically create a new mpeg with cc appended to the file name.
What is the command to run winrtvcc in the same directory as the as the original mpeg on the original mpeg? What is the command to del the original after winrtvcc is finished? What is the command to then run comskip in the same directory?
Bargonaut
12-30-06, 03:44 AM
If you want to call your bat file with the filename to process, then it has one parameter. Use %1% as the first parameter to your bat file. %2% as the second, etc.
Assume you have a video file: foobar.mpg and the bat file is named "clipads.bat"
You'd call the script as "clipads foobar" and end up with a foobar.cc.mpg and foobar.vprj
If you need to specify the Redo project name, make it another parameter (%2%).
I hope this gets you started. Be careful with the delete command until you are sure it actually creates the desired output first. In other words, work on a copy.
HTH,
-B
8<--------------------------------------------cut here-----------------------
rem Change to the directory with the programs and video files
cd \apps\comskip
rem Run WinRTVcc on the file specified
winrtvcc "%1%.mpg"
rem Run vidoRedo on the output file of WinRTVcc
cscript //nologo "c:\program files\videoredoPlus\AdScan.vbs" "%1%.cc.mpg" "%1%.vprj"
rem Delete the original video file
del %1%.mpg
SpaceCadet
12-31-06, 11:52 AM
[Edit - early version of command/batch file was superceded.]
Thanks, I'll look into it next year.
SpaceCadet
01-01-07, 09:22 PM
[Edit--Superceded.]
Thanks for the help. Unfortunately, I still haven't had time to play with it.
Good work! I will get a chance to try it out this weekend, been out of town all week. I will let you know what i find out.
Thanks for all your hard work!
SpaceCadet
01-15-07, 04:58 AM
Added some important improvements. It can now skip processing of previously-processed files when you don't specify a destination folder--in which case the output files will go into the source file folder--and the source disposition is other than replace--in which case the output filenames consist of the input filenames with text appended (default is "_cln").
The script already allowed substitution of executables with others that had the same parameters. It now allows command/batch files to be substituted for the executables, which provides a convenient and easy way for the user to supply additional parameters to the executables (an example is documented in the file). VideoReDo Plus is an exception, since it uses scripts. Later, I'll add options to pass additional parameters into those scripts (for now, you can always edit those lines of the command file).
Since there are a lot more views of this thread than downloads of the file, some people may not be aware of what this script does (of course, I realize that it may only be of value to a couple of people). So here is a brief description:
Basically, this command file automates some common tasks on ReplayTV and other MPEG-2 files, DVR-MS files, and VideoReDo Plus .VPrj files. You select which operations you want performed, and you only need the executables for those operations. The command file handles temporary files, file placement and naming, checking for free disk space, error handling, etc. It makes a small effort to locate executables without having to specify their location in the command file. Drag-and-drop of folders and multiple-file groups is supported, as are wildcards if called from the command line or another command/batch file. Default options may be set in the file and overridden in shortcuts to the command file, on the command line, and in command/batch files. So far, the following operations are supported:
Standardize ReplayTV captions
Fix ReplayTV audio bug
Fix various MPEG-2 problems via VideoReDo Plus' QuickStream Fix
Detect commercials via Comskip, ShowAnalyzer (indirectly supported), or VideoReDo Plus
Commercials may be cut automatically, or cut after the user has reviewed and edited the cut marks. This operation is done via VideoReDoPlus, which also fixes various MPEG-2 problems.
Like any command/batch file, it's just text. From Windows Explorer, right-click the .cmd file and select "Edit" to see/change it. You can turn Echo On or insert Echo On/Off surrounding areas that you want to see the macro expansion for. From the command prompt, it supports the standard DOS/Windows help request /?. *Important*--when editing command files, do not allow word wrap to break up lines. In NotePad, make sure Format->Word Wrap is *unchecked*.
I'm also placing a couple of other trivial Windows XP command files here that some may find useful.
HardLink is a trivial little command file (remarks but no help display, minimal checks) that creates hardlinks to files that are dragged-and-dropped onto it (or a shortcut) in the source files' folders. This is only for NTFS volumes (I haven't tested it on Vista). On NTFS volumes, all filenames are hardlinks to the data for those files (via file directories). So, you can have more than one filename which share the same file data and file attributes. This can be handy for large media files, as you can put them in multiple folders but have only one copy of the data. Read the remarks in the file for additional information.
RegShot is an XP command file that schedules Regshot (http://regshot.blog.googlepages.com/regshot.html) to run with System privileges, so that you can get a complete Windows Registry snapshot. Regshot is crappy and buggy, but basically useful; it creates Registry snapshots and can compare them. Registry snapshots are essential for tracking installations (along with file monitoring). There's probably better freeware, but I haven't hunted around. Registry snapshots are quite large; I use 7-Zip, but version control software would be even better.
Note: Windows security warnings--Windows will complain that "the publisher could not be verified", which is true. It will also say that there is no digital signature, which is correct but misleading--command/batch files are text files, so they can't have digital signatures, which are binary data. When you download software that has an installer, you may get the warning on the installer, but you won't get the warning on software and files that the installer installs on your computer. When you download executables or extract files from a downloaded archive, you'll get the warning on all of the files from the archive. If you execute those programs and they use other files that were extracted from the archive, Windows may block those files without warning you, thereby preventing the program from functioning correctly, such as preventing display of its help file. You need to right-click each file, select Properties, and select Unblock (if you don't see the Unblock option, it's not blocked).
Internet Explorer users--right-click and Save Target As...
SpaceCadet
01-17-07, 10:09 AM
The option to skip processing of already-processed files that have been renamed has been removed--they will not be processed. Added processing of entire folders via the command line or drag-and-drop. Attachment was updated in previous post.
dherman516
01-17-07, 02:25 PM
Love the RTVCleaner script... only wish it had a encode to DIVx funciton ;)
SpaceCadet
01-18-07, 01:37 AM
Thanks, dherman516. You may be the only user so far. I really haven't had much time to work on this. There are many more features that I'll be adding before it reaches version 1.0. At that time, it will be fully tested and I will move it to its own thread. Until then, one should read the comments directed at the user that are at the top of the file, including the options, very carefully when new versions come out--that's where I document what's available.
One obvious problem that I've run into before when someone requested a ReplayTV script, is that the Windows command/batch language does not have a way to request exclusive access to a file. This makes it very difficult to determine whether a file is still being written. Some people claim that you can check the file size, but that doesn't work. It can take literally minutes for a change in file size to show up under XP (I don't know whether this is because of buffering, something to do with NTFS, or something to do with the way XP handles file size requests). I've looked at other methods available to a command file--renaming, the archive flag, timestamps, reading the file--nothing works. I would hate to have to call a utility that wasn't already part of XP just for the sole purpose of determining whether a file was in use, but I may have to. In the meantime, users should be aware that processing a file that is still being created may result in uncaught errors (a result file that is only partial).
[Update] I noticed that this is primarily due to buffering/space allocation by the application that is writing the file. Some applications write the file almost continually, others, such as MCE, can go many minutes between noticeable updates to an open file. MCE allocates file space in large chunks, to reduce fragmentation and overhead. Another chunk isn't allocated until the previous one is filled, so that's why the file size doesn't change for long periods of time.
dherman516
01-18-07, 12:00 PM
Again, I used your script all last weekend to clean my "collection" of "that 70s show".
It worked real well and saved me a bunch of time too!.
Another enhancement to your script could be to re-integrate the cleaned MPG into DVArchive to share
SpaceCadet
01-20-07, 11:18 AM
Updated attachment in post #8. Will process DVR-MS files (doesn't convert to/from MPEG-2 yet, but that's coming)--works well with MCE (I won't touch that DVRMS-Toolbox crap). Allows .MPEG extension as well as .MPG (.MPEG skips ReplayTV-specific processing). Hopefully, I didn't break more than I fixed.
SpaceCadet
01-21-07, 11:15 AM
It will probably be several days before I post a new version, so I updated the attachment in post #8--mostly important documentation changes for SourceDisp and DestFolder regarding folder drag-and-drop (or folder specification on the command line).
SpaceCadet
01-23-07, 01:03 AM
Dan Rosen, from DRD Systems, Inc. (VideoReDo Plus) recommended getting the VideoReDo Plus installation folder from the Registry, so I implemented that, and restructured the code related to finding executables.
SpaceCadet
01-23-07, 10:23 PM
I noticed folder processing hadn't been updated, fixed that and noticed it wasn't functioning as expected, so I fixed it (or at least, as much as I've tested it). If anyone is actually using this, you can report bugs and I'll fix them. As I have stated, this is preview code that is in flux, but I would like for it to be functional. I need to test some of the For loops that are within compound statements; depending upon nesting they can do very strange and unexpected things (I'm not talking about programming mistakes--the interpreter can do bizarre things).
I've seen three types of bugs in the interpreter. The easiest to spot is incorrect expansion (clearly not due to coding error--text that isn't present in the command file, local or global variables, or arguments). Tougher are skipped values in For loops--a coding error could cause a loop to terminate, but it can't cause an earlier For-variable value to be skipped. Hardest to spot are cases where the interpreter parses a compound statement, but fails to execute a portion of it (a typical situation is a compound If statement--the expansion will show a clear condition met, but the code for that case will not be executed). Generally, earlier and later portions of the compound statement will execute correctly. When these situations occur, you have no choice but to change the code.
abit late
01-24-07, 05:09 PM
Thanks SpaceCadet for this great script and for the help you gave me in the other forum.
You mention running the script periodically as a scheduled task. How should I go about doing this for all files in a folder, i.e. schedule a drag and drop such that all contents of a folder are processed?
SpaceCadet
01-25-07, 02:34 AM
Updated script with documentation to run as a Scheduled Task. Added /NonInteractive option for that purpose. Since people are using this script for different purposes, the default for all operations is now none. It seems more logical to enable the operations that you want than to disable the ones that you don't.
SpaceCadet
01-25-07, 11:30 AM
The joys of software.... The recommended method of finding VideoReDo Plus doesn't work when scheduled as a system-level task; modified to use multiple methods. Modified to support VideoReDo Plus' new .VPrj format.
orbitzboy
01-26-07, 12:59 PM
spacecadet,
Good stuff!
Just downloaded it - when I get more time, I'll dig in. This may make my replayTV valuable again for autoarchiving.
SpaceCadet
01-26-07, 04:06 PM
While I'm certainly not going to publicly commit to any features for something that I'm doing for free in my little spare time (in the world's worst programming language), these are the things that I'll be looking into implementing (priorities keep changing based on feedback):
Something that I was going to put off until later when the list of options was more complete but will probably do soon because it's helpful to me when testing: Some renaming of options, and a shorthand method for entering options on the command line (will save me some typing). Full naming of options will remain recommended for use outside of the command line for later readability and to facilitate accommodating to options that get renamed.
Something interesting with VideoReDo Plus for those who want fully automated commercial removal.
Support for more options in the called utilities.
Direct support for ShowAnalyzer.
Support for more types of MPEG-2 containers, and conversions between them.
Support for transcoding.
Support to DVArchive, and from and back to DVArchive (a couple of years ago I wrote a command script that supported the multiple-drive features of DVArchive, but I probably won't support that in this script because it does/will do a lot of different things).
Possibly some special support for MCE->DVArchive.
A special thanks to everyone who has posted in this thread or sent me a PM. This script is of no value if it doesn't do what people want, or if the documentation isn't adequate. The only way that I can make it useful is by potential users giving feedback, which is why I have been making early versions available---it's a lot easier to accommodate code changes early on, especially when using such an incredibly primitive language as the Windows batch/command language, which doesn't support any good software engineering features.
abit late
01-30-07, 09:19 AM
This script has been a great addition to my PC's workload and I look forward to the new additions! Particularly something interesting with VideoReDo Plus for those who want fully automated commercial removal. Although I haven't had much luck with getting VRD to reliably remove commercials with as yet.
I use GBPVR and tried to get the script to run after each recording by putting it in the GBPVR directory and renaming it Postprocessing.bat. It works but only for 1 recording, i.e. when the second recording is done the file is not processed. Do you know why this could be? Could one or more processes not be closed when the script is run in this way? I would like it to work as a Postprocessing.bat file but for now I have scheduled it to run twice a day on all files then delete the original - just for QSF.
Thanks again for your great script.
Al
I am just letting you know I have finally read rtvcleaner.cmd in notepad and as far as I can tell it should be awesome. You did a great job, very detailed and thoroughly explained. I think I will have questions once I use it. I haven't used it yet because I am always short on time.
I just used it and it works great. I only used rtvcc and comskip. Can you add in an option for mpg2srt?
Also, I am trying to figure out if I want to use automated commercial removal. I guesstimate 10%-20% of my shows have errors in the com detection but I may be able to fix that by tweaking comskip.ini. I need to find more time for that. I did change min_commercialbreak=100 and min_commercial_size=15. So that should keep short pieces I don't want lost. It is worst to lose a scene than keep a short commercial.
If you do add in DVArchive support that would be great, seeing as how I haven't had the time to buy another HTPC and sell my RTV. Even so, I am sure there are plenty of others out there using a dual HTPC and RTV setup.
SpaceCadet
01-31-07, 03:07 AM
Sorry for the delayed response, been busy with mundane things. abit late, comskip does a better job detecting commercials than VideoReDo Plus does (comskip is free); nothing available does a great job (they all do a poor job of utilizing available information). As for the GBPVR problem, since I don't use GBPVR, I can't help you with that. If you see a command window popup when GBPVR is running Postprocessing.bat, then it's unlikely that a process has hung. If, like a scheduled task, you don't see anything, then you can check running processes. Although there are more sophisticated tools, you can use the Windows Task Manager. Press Ctrl-Alt-Delete (only once) and the Windows Task Manager will pop up. Click the Processes tab, click on the Image Name column heading, look for Cmd.exe. If it's there when Postprocessing.bat shouldn't be running, then there may be a problem. Otherwise, it has something to do with GBPVR; I'm sure GBPVR has a forum.
There are two types of users when it comes to commercial removal--those who want to archive shows with 100% accurate commercial removal, and users who simply want automated removal so that they don't have to watch commercials. The only way to get 100% accurate removal with current products is with manual intervention. For fully automated removal, what I will be implementing is appending the cuts after the cut program. The file size will remain essentially the same, but the order of show segments will be changed by the cut process. If a scene that should not have been cut by commercial detection is cut, it will be after the rest of the show, with the commercials. Not a great solution, but better than losing a critical scene, and it does allow the original file to be deleted to save space. It involves a bit of code because I have to handle the old and new .VPrj file formats, use the VideoReDo Plus COM interface, and do extended-precision arithmetic (command files only have 32-bit signed integer arithmetic directly supported).
DVArchive support will definitely involve some coding. Getting a show into DVArchive isn't a big deal; I'll need to use the VideoReDo Plus COM interface to get some information, such as show duration. Getting a show from DVArchive, processing it, and putting it back is a headache, because it involves multiple files per show that I have to keep track of (particularly a pain when dealing with temporary file handling), extract information from, store information when the process is interrupted by manual .VPrj editing, etc.
OK, I'll add mpg2srt to the long to-do list. I've been busy with other things the past few days (and Monday was Heroes night, one of the few shows that I still enjoy--this is the last season of the Apprentice that I'm going to watch, Battlestar Galactica has turned into a soap opera, etc.)
Heroes has turned out to be popular.
SpaceCadet
01-31-07, 06:14 PM
I use GBPVR and tried to get the script to run after each recording by putting it in the GBPVR directory and renaming it Postprocessing.bat.I looked up the documentation for PostProcessing.bat. What you need to do is create a separate PostProcessing.bat file that calls RTVCleaner. The PostProcessing.bat file should consist of the following line:
Call RTVCleaner.cmd /NonInteractive %1 2>>RTVCleaner.log
Of course, you can change the RTVCleaner options and logging options, as documented in RTVCleaner.
I finally had sometime to test your batch file with videredo plus. Your right when you say there is no real way as of yet to get 100% perfect auto cuts. I have to say your batch script is the best thing so far i have come across! Thanks for all your hard work and i am looking foward to your upcoming VideoRedo Plus tweaks.
Hopefully in the near future i will have some more time to help test, between work travel and family time. :)
Just wondering how you are doing with the tweaks? Been awhile since we heard anything.
Thanks again for a killer program!
SpaceCadet
04-12-07, 03:51 PM
Thanks for reminding me about this. I had started to add additional features, and then got sidetracked by other things. I'll start working on this again. Note that VideoReDo Plus is undergoing changes in preparation for new features. I added a couple of more little command files to post #8, which people may or may not find useful (read the post).
vBulletin® v3.7.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.