From the computer of: seamonkey420
(131 recipes)
Created: Apr 08, 2006
Requirements:
-Windows XP (any flavor) or 98 (i believe the statements will read fine)
-Basic understanding of .bat files
-Full batch file contents for converting in sagetv (http://forums.sagetv.com/forums/showthread.php?t=10709)
Overview:
This recipes is another of my sagetv/htpc based ones but also can be used for much more! This recipe will explain how to use a For statement in a way you never though you could. For statements can allow one to send data to apps via command line (if they support this..), move data, create webportals, and more!..
Also, i've included my own date parsing code too.. its handy to have and hard to find on the web..
Date Code:
usuage: use in any batch file you need to use the current date in a MMDDYYYY format. can be called in script by %date, place in begining of script.
| Quote: |
| @REM parses month, day, and year into mm , dd, yyyy formats to create folders off of!
FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%B FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN ('DATE/T') DO SET mm=%%B FOR /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('echo %CDATE%') DO SET dd=%%B FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN ('echo %CDATE%') DO SET yyyy=%%B SET date=%mm%%dd%%yyyy% |
this is a crazy looking batch file yet its not as complex as it may seem... This file will basically allow one to check a dir for a file, if it exists, it will then run a series of commands on the files: encode to wmv, create a webportal structure w/embedded windows media player in them, and also move files and cleanup files.
i've explained each line with a remark. this code heavily uses variables, so that way you can make changes to it very easily without it breaking. you can change the file type your are using as your source file or the file extension your encoding to and of course folder locations...
i've used the for statement to check for the existence of files, however one could setup it up to be ran manually or called by windows scheduler..
hopefully that helped you enough to get on your way.. peace
seamonkey420
____
NOTE, the readme i include w/the version at sage.tv's forums boards..
get all of the files for batch file here:
http://forums.sagetv.com/forums/showthread.php?t=10709
| Quote: |
| Overview: Well.. its amazing what a little time, thinking, discussing, and testing can accomplish. I know that currently ajuhawk has created an application to do most of this and more, but i'm a fan of the batch file still.. so here's the latest of my batch files..
Notes: This DOES NOT handle compression in SageTV. Movies/shows may be encoded more than once if compression is used. Installation: required programs: -SageTV -Cayars Ultimate STV installed -Windows Media Encoder 9 ( click to go to download page) -PSP Video 9 ( http://pspvideo9.com ) -Videora ( http://videora.com ) _________ where to put files -wme.bat (put in windows media encoder folder, ie C:\Program Files\Windows Media Components\Encoder) -psp.prx or whatever you call your windows media encoder profile (put in windows media encoder folder, ie C:\Program Files\Windows Media Components\Encoder) -all the .txt files (ie embedS.txt, embedE.txt, indexS.txt, etc..) (put in windows media encoder folder, ie C:\Program Files\Windows Media Components\Encoder) -put the Encode.cmd into your cayars\external folder (ie C:\Program Files\Frey Technologies\SageTV\STVs\OriginalV2\cayars\External ) _________ files that need to modified! -wme.bat you will need to change the idir and the odir parameters. the idir is the location sagetv saves your tv recordings the odir is the locations you want to save your encoded files to (note, this batch will create a new folder in this directory with the date stamp (mmddyyyy format)) here are the parameters that can be changed/need (with examples) and what they refer to: set idir=T:\Recorded Shows (where sagetv saves the mpgs of tv shows) set odir=T:\Encoded Shows (where you want to create your encoded tv show webportal) set oFile=wmv (file type you want to encode to) set profile=psp.prx (windows media player profile to use) set ldir=T:\Recorded Shows\Log (location of log folder, be sure to create it before running!!) set trigger=VPrj (main trigger file ) set pdir=T:\Recorded Shows\PSP (location that PSP Video 9 looks for movies to auto-convert) also, if you want to have the batch search for a different file type to trigger the encoding, you can do so here too, by default i have it set to look for a .VPrj file. -.txt files modify these files to your liking, i would suggest to run the script/batch first and see how things look. these files are basically templates i have my batch use to create the webapges and embed the movie into a webpage. -Encode.cmd (put and located in C:\Program Files\Frey Technologies\SageTV\STVs\OriginalV2\cayars\External) edit this batch, so that it points to where you to where the wme.bat is saved (C:\Program Files\Windows Media Components\Encoder\wme.bat) -then once you have all of this done, in Cayars Ultimate STV. you can add a menu item to point to this file. -Right Click in the menu/submenu you want to add the encoding option. -Choose Add New Menu Item > External Program -Then, for external program, use: cmd.exe -Then for arguments/parameters use: /C "C:\Program Files\Frey Technologies\SageTV\STVs\OriginalV2\cayars\External\Encode.cmd" (you can copy this line, then use the Paste From Clipboard option) -Then enter the menu title/text to show: ie, Encode and Publish -Then once your done, right click again and now Save Menu Definition File. Hopefully you should now be able to just click the option and the encoding will start automatically in teh background.!! ________ here's exactly what the batch does: 1. in sagetv, click the new menu item we added that points to the batch/encode script 2. this calls our wme.bat script. this script does it all! 3. first it creates a new folder is created with the current date mmddyyyy (ie 03192005) 4. it then will check for a .VPrj file in the idir 5. if it finds one, it will then check the log file folder for a log, if not 6. it will then go and encode all the mpg movies that have a .VPrj file using windows media encoder and the profile we saved in the psp.prx 7. once it finishes encoding the .VPrj it will go back and then create a webpage file, .html with the show name/episode (ie FamilyGuyFunnyDay-3.html) in the folder that was created (ie 03192005/FamilyGuyFunnyDay-3.html) 8. After the embedded webpage is created, it will go back and then create a main index.html file for that folder (ie 03192005\index.html) 9. After the date index is created, another index is then created, with links to all of the index.html files that might exist. 10. and finally once this is done, the batch will go back and clean up all of the files assocatied with the newly encoded wmv (ie , ccno, txt, log, etc) if it successfully encoded. And also move the mpg to the psp folder (for psp video to auto-convert later). However, if encoding of the mpg failed, the original mpg is left alone. 11. then it will do some quick orphaned file cleanup... |
Subscribe to the Tech-Recipes Newsletter
You can get tips like this delivered in your email every week!
We will never, ever sell your email address or spam you.
Related recipes:
Supressing Prompts In Batch Files While Deleting All Files
Supress Responses From Commands In Batch Files
Using variables in Windows batch files
XP batch files: Create variable for current user account and find current user
Batch Files : Get users default printer via registry (WinXP)
XCOPY command : Using the /EXCLUDE flag
Create Batch File to Start or End Window Services
XP Batch Files: Copy images from camera to pc and organize by date
Processing the contents of a text file using FOR loop
Windows XP/Vista: Use a Batch File for Quickly Restarting explorer.exe
Sponsored links
Login
Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.Search
Tech Recipes
· Home
· Mac OS X
· Solaris
· Windows
· Programming
· UNIX
· Cisco
· MySQL
· Google
· Instant messaging
· Add recipes
· Leave feedback
· Recommend us
· RSS Syndication
Hot recipes
Make XP look like Windows Vista / Longhorn for free!
SMS through E-Mail: Cingular, Nextel, Sprint, T-Mobile, Verizon, Virgin Mobile
XP: Small, Free Way to Use and Mount Images (ISO files) Without Burning Them
Vista: Should I Install 64-bit or 32-bit Version? (x64 vs x86)
Hacks to Beat Rapidshare Download Limits and Waiting Time
MySpace Hack: View Pictures and Comments on a Private Profile
How Do I Use or Open Bin, Cue, or ISO Files?
MySpace: Hack to Download Any Song on MySpace
Who's Online
There are currently, 2866 guest(s) and 1 member(s) that are online.
You are Anonymous user. You can register for free by clicking here
Information
Wish to advertise with us?
All logos and trademarks in this site are property of their respective owner. The comments and forum posts are property of their posters, all the rest © 2003-2007 by QD Ideas, LLC.
Users of this site are legally bound by the Terms and conditions and Disclaimer. Do not use this web site if you do not agree with these policies.
The members, admins, and authors of this website respect your privacy.
Page Generation: 0.78 Seconds
Fri Aug 8 13:47:01 2008