View Full Version : batch script editing
moko
1st April 2003, 23:05
I trying to make a DVD backup and when I created the scripts I ended up with 84 scripts (a lot of transition effects in the menu...). Then, I noticed that I forgot to add ConvertToYUY2 at the end of every script so that CCE will accept it, and I really don't want to start editing every single script. Now I know that this may be a little off the forum topic but it's avisynth after all so if anyone knows if I can do sort of batch editing let me know asap.
IanB
2nd April 2003, 00:16
The crude (dos) way :-
Create a temp folder.
Move (Copy?) all the target .AVS's into the folder.
Launch a Dos box.
Cd to the temp directory.
And typeFor %I in (*.avs) Do Echo ConvertToYUY2()>>%IThis will append the line to the end of each file.
IanB
moko
3rd April 2003, 12:44
Well, I tried this command and what I got was a file called %I with no extention in the same folder, that has 84 lines of ConvertToYUY2(). Any other way?
bilu
3rd April 2003, 12:56
If you use it inside a batch file you have to use %%I instead of %I.
Bilu
moko
3rd April 2003, 21:45
bilu: I know that. when I used that command inside a batch file the result was the same only the file was called just I instead of %I.
bilu
3rd April 2003, 22:04
I can't understand :confused: , it should work even on DOS 6.22 ...
What Windows are you using?
moko
3rd April 2003, 22:19
Well, I have problems running 2k/xp on my system :( so I use win 98 se...
EDIT: maybe the problem has anything to do with long file names?
bilu
4th April 2003, 01:43
Please try and give feedback.
Bilu
Belgabor
4th April 2003, 10:48
You could try using msys (something like a stripped down cygwin to work with mingw). I prefer it to the normal windoze CLI (well, maybe because I'm more used to linux CLI interface now ^^'). Still it sometimes can do what windoze can't (e.g. rename a file to start with a '.').
Anyways, if I remember sh scripting correctly the same line should work, only you should write 'for' lowercase and use '$' intead of '%'.
EDIT:
Ok, its more complicated than that:
for I in *.avs; do echo "ConvertToYUY2()" >> "$I"; done
moko
4th April 2003, 14:04
Belgabor: where can I get this msys?
EDIT: do I also need cygwin for that? coz I can't get to download it properly. a good link will be great.
The Link
4th April 2003, 14:21
http://www.mingw.org/msys.shtml
moko
5th April 2003, 14:11
The Link: thanks for the quick link!
Belgabor: took me some time to get along with msys, but finally I mangaged to get into the directory, when I entered the command you wrote I got this message:
sh: *.avs: No such file or directory
Am I doing something wrong or should I try something else?
IanB
5th April 2003, 15:36
@moko sorry for the slight bum steer. I should have tested what I originally sent. The >> applies to the overall "For" command not to the expanded "Echo" commands. All is not lost I have a workaround.
create a TEMP.BAT file (use notepad or an editor) with the following single line content :-Echo ConvertToYUY2()>>%1Note this is "percent sign" "digit one".
and then type the following command :-For %I in (*.avs) Do Call TEMP.BAT %INote the is "percent sign" "letter I".
This I have actually tested under Windows 98 and it does append the line to all the *.avs files in a directory.
If you can't get any of these automatic methods to work use brute force. DoDir /B *.avs>TEMP.TMP to get a list of filenames and then use a good editor (wordpad, edit??) to massage the file into an 84 line batch file that does the followingEcho ConvertToYUY2()>>File1.avs
Echo ConvertToYUY2()>>File2.avs
Echo ConvertToYUY2()>>File3.avs
...
Echo ConvertToYUY2()>>File84.avsthen run the batch file...
Good luck
IanB
moko
5th April 2003, 22:59
IanB: thanks a lot for the reply, this time it really worked. However, there's still one problem: the ConvertToYUY2() line is appended right next to the last line and not in a new line as I want it to be. For example, if my script was like that:
LoadPlugin("MPEG2Dec3.dll")
MPEG2Source("file.d2v")
Then the result will be:
LoadPlugin("MPEG2Dec3.dll")
MPEG2Source("file.d2v")ConvertToYUY2()
And of course I need it like this:
LoadPlugin("MPEG2Dec3.dll")
MPEG2Source("file.d2v")
ConvertToYUY2()
EDIT: ok, I noticed that when I ran the second batch again (the files still with the unwanted result) it worked just right. why is that?
IanB
7th April 2003, 04:11
Originally posted by moko
However, there's still one problem: the ConvertToYUY2() line is appended right next to the last line and not in a new line as I want it to be.
....The Dos append ">>" construct just adds bytes to the end of the file. If the file did not end with a Cr-Lf sequence then you will get the effect seen.
To protect against this easy to occur problem, append a blank line first. If the file already ended with a Cr-Lf then you get a harmless blank line, if not then you just get the protection you were after.
Just create a TEMP.BAT file with the following two line content :-Echo.>>%1
Echo ConvertToYUY2()>>%1note "Echo.>>%1" must have no spaces and the "." is important.
IanB
moko
7th April 2003, 22:45
IanB, first I would like to thank you for all your replies for this thread and the great help you provided.
Eventualy I noticed that the problem accured because a new line was not present so what I did was first add a '#' sign that also created a new line for me and then added the ConvertToYUY2() line. But I think that your final solution of adding a new line using echo. (didn't know about this...) is better.
Richard Berg
8th April 2003, 08:28
FWIW, the original problem lies in the Win9x command interpreter -- only NT supports the expanded FOR command.
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.