new to batch scripting
Moderator: DosItHelp
-
- Posts: 9
- Joined: 06 Dec 2014 16:37
new to batch scripting
I am working on a script to do multiple things to files. my work path is this:
1. incoming folder >transcode file > delete old .flv file then rename new .mp4 to "filename"-newpart.mp4 > then move new named file to next folder.
2. for thumbnailing and media info.
I have the command for transcoding and thumbnailing, but renaming and moving/deleteing along with how to work everything together is giving me problems. If the batch files need to be in the work folder it's no problem.
my transcode batch command is as follows:
@echo off
for %%a in ("*.flv") do ffmpeg -i %%a -i C:\watermark.png -filter_complex overlay=main_w-overlay_w-1:1 -b:v 300k -r 15 -vcodec libx264 -acodec libvo_aacenc -ac 1 -ar 22050 -b:a 48k -coder 1 -threads 2 -n %%~na.mp4
pause
this works alone with zero problems.
currently i have the thumbnail command worked out just not as a batch file:
C:\mtn-200808a-win32\mtn-200808a-win32\mtn.exe -c 5-r 5 -h 100 -L :4 -N .txt
Like I said these are the only 2 parts i have right now. I would like to automate this process.
Any help is appreciated.
Thanks
1. incoming folder >transcode file > delete old .flv file then rename new .mp4 to "filename"-newpart.mp4 > then move new named file to next folder.
2. for thumbnailing and media info.
I have the command for transcoding and thumbnailing, but renaming and moving/deleteing along with how to work everything together is giving me problems. If the batch files need to be in the work folder it's no problem.
my transcode batch command is as follows:
@echo off
for %%a in ("*.flv") do ffmpeg -i %%a -i C:\watermark.png -filter_complex overlay=main_w-overlay_w-1:1 -b:v 300k -r 15 -vcodec libx264 -acodec libvo_aacenc -ac 1 -ar 22050 -b:a 48k -coder 1 -threads 2 -n %%~na.mp4
pause
this works alone with zero problems.
currently i have the thumbnail command worked out just not as a batch file:
C:\mtn-200808a-win32\mtn-200808a-win32\mtn.exe -c 5-r 5 -h 100 -L :4 -N .txt
Like I said these are the only 2 parts i have right now. I would like to automate this process.
Any help is appreciated.
Thanks
Re: new to batch scripting
This modification will create the filename you mentioned, and then move it - and repeat for all the files.
Note that the ffmpeg command is still on only one line.
Where does this command use the input and output filenames?
Note that the ffmpeg command is still on only one line.
Code: Select all
@echo off
for %%a in ("*.flv") do (
ffmpeg -i %%a -i C:\watermark.png -filter_complex overlay=main_w-overlay_w-1:1 -b:v 300k -r 15 -vcodec libx264 -acodec libvo_aacenc -ac 1 -ar 22050 -b:a 48k -coder 1 -threads 2 -n "%%~na-newpart.mp4"
move "%%~na-newpart.mp4" "c:\newfolder"
)
pause
Where does this command use the input and output filenames?
Code: Select all
C:\mtn-200808a-win32\mtn-200808a-win32\mtn.exe -c 5-r 5 -h 100 -L :4 -N .txt
-
- Posts: 9
- Joined: 06 Dec 2014 16:37
Re: new to batch scripting
foxidrive wrote:[/code]
Where does this command use the input and output filenames?Code: Select all
C:\mtn-200808a-win32\mtn-200808a-win32\mtn.exe -c 5-r 5 -h 100 -L :4 -N .txt
This is the thumbnail command i have. I was thinking about making it part of the script with the transcode. If it's possible i wanted to have it run after the move command in the new folder, otherwise i will have it run separately.
the transcode works flawlessly, Thanks. Is it possible to add in a delete for the trans-coded .flv files?
Re: new to batch scripting
frostedflakes wrote:Code: Select all
C:\mtn-200808a-win32\mtn-200808a-win32\mtn.exe -c 5-r 5 -h 100 -L :4 -N .txt
This is the thumbnail command i have.
Can you paste that line into the cmd prompt and see if it works?
i wanted to have it run after the move command in the new folder
Is it possible to add in a delete for the trans-coded .flv files?
Those things are possible.
Add this on the line after the move command to delete the FLV file after processing.
Be aware that it does not check if the file was created successfully, such as if the disk is full.
Code: Select all
del "%%a"
Change this ffmpeg -i %%a to this ffmpeg -i "%%a" and it will also handle spaces and other characters in filenames.
-
- Posts: 9
- Joined: 06 Dec 2014 16:37
Re: new to batch scripting
foxidrive wrote:frostedflakes wrote:Code: Select all
C:\mtn-200808a-win32\mtn-200808a-win32\mtn.exe -c 5-r 5 -h 100 -L :4 -N .txt
This is the thumbnail command i have.
Can you paste that line into the cmd prompt and see if it works?
Yes. command line is where i got it to work. the problem I see is that i have to run it from the mtn.exe folder, I have set the path in System Variables to run outside of the folder but it doesn't. My only way to get to work is this:
C:\mtn-200808a-win32\mtn-200808a-win32\mtn.exe -c 5-r 5 -h 100 -L :4 -N .txt C:\thumbnailing folder with videos\
is it possible to use this on an individual video basis? So I may have this::
transcode>>rename>>move>>completed.mp4>>del completed.flv>>in new folder run mtn.exe command. from here i can manually move them to upload folder.
Once again Thanks for your help..
Re: new to batch scripting
Can we see the path variable please.
-
- Posts: 9
- Joined: 06 Dec 2014 16:37
Re: new to batch scripting
Squashman wrote:Can we see the path variable please.
This is what I have so far::
@echo off
for %%a in ("*.*") do (
ffmpeg -i "%%a" -i C:\watermark.png -filter_complex overlay=main_w-overlay_w-1:1 -b:v 300k -r 15 -vcodec libx264 -acodec libvo_aacenc -ac 1 -ar 22050 -b:a 48k -coder 1 -threads 2 -n "%%~na-MyFreecams.mp4"
move "%%~na-newpart.mp4" "c:\path\to\new\folder\"
del "%%a"
)
fi
then
CD=C:\path\to\new\folder\
CALL mtn.exe -c 5 -r 5 -h 100 -L :4 -N .txt %CD%
The BOLD part is what I am trying myself, I don't think it will work. If you can provide options it will be great.
-
- Expert
- Posts: 1167
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: new to batch scripting
CD is already a command in batch, and when you use it as a variable, it returns the directory you're currently in.
fi and then aren't batch commands; I'm not sure what you're trying to do there. I know then is used in if statements in VBA (and I assume Visual Basic) and fi ends if statements in some languages, but you don't have any if statements.
fi and then aren't batch commands; I'm not sure what you're trying to do there. I know then is used in if statements in VBA (and I assume Visual Basic) and fi ends if statements in some languages, but you don't have any if statements.
-
- Posts: 9
- Joined: 06 Dec 2014 16:37
Re: new to batch scripting
echo off
for %%a in ("*.*") do (
ffmpeg -i "%%a" -i C:\watermark.png -filter_complex overlay=main_w-overlay_w-1:1 -b:v 300k -r 15 -vcodec libx264 -acodec libvo_aacenc -ac 1 -ar 22050 -b:a 48k -coder 1 -threads 2 -n "%%~na-MyFreecams.mp4"
move "%%~na-newpart.mp4" "c:\path\to\new\folder\"
del "%%a"
)
fi
then
CD=C:\path\to\new\folder\
CALL mtn.exe -c 5 -r 5 -h 100 -L :4 -N .txt %CD%
With this I was trying to call the next batch command which is capper.bat the mtn.exe is the command.
I am wondering now if i can start capper.bat if a new video file is put into a new directory, like this:
trasncode done>>del old file>>move new file to new folder>>when new file enters new folder start capper.bat..then new file enters, rerun capper.bat.
Is this possible? Do you undestand what I am looking for? Sometimes I am not clear...
-
- Expert
- Posts: 1167
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: new to batch scripting
What you want is possible. Try using start instead of call.
Disclaimer: I didn't see anything on http://moviethumbnail.sourceforge.net/usage.en.html about the -L usage so I don't know if that part is correct.
Code: Select all
REM The first "" is for the title so that the rest of the command actually works
start "" mtn.exe -c 5 -r 5 -h 100 -L :4 -N .txt "C:\path\to\new\folder"
Disclaimer: I didn't see anything on http://moviethumbnail.sourceforge.net/usage.en.html about the -L usage so I don't know if that part is correct.
Re: new to batch scripting
I asked to see the system path variable that you said you changed.
-
- Posts: 9
- Joined: 06 Dec 2014 16:37
Re: new to batch scripting
for System Variable, I added C:\mtn-200808a-win32\mtn-200808a-win32\; to the end of the variable name PATH.
Re: new to batch scripting
frostedflakes wrote:for System Variable, I added C:\mtn-200808a-win32\mtn-200808a-win32\; to the end of the variable name PATH.
Well I am not going to ask a third time for information. I am done with this thread.
-
- Expert
- Posts: 1167
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: new to batch scripting
frostedflakes wrote:for System Variable, I added C:\mtn-200808a-win32\mtn-200808a-win32\; to the end of the variable name PATH.
Please post the entire output of
Code: Select all
echo %path%
-
- Posts: 9
- Joined: 06 Dec 2014 16:37
Re: new to batch scripting
Please post the entire output ofCode: Select all
echo %path%
C:\ProgramData\Oracle\Java\javapath;c:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Broadcom\Broadcom 802.11 Network Adapter;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\mtn-win32;C:\mtn-win32;