new to batch scripting

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
frostedflakes
Posts: 9
Joined: 06 Dec 2014 16:37

new to batch scripting

#1 Post by frostedflakes » 07 Dec 2014 23:54

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

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: new to batch scripting

#2 Post by foxidrive » 08 Dec 2014 04:49

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.

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

frostedflakes
Posts: 9
Joined: 06 Dec 2014 16:37

Re: new to batch scripting

#3 Post by frostedflakes » 08 Dec 2014 05:37

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?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: new to batch scripting

#4 Post by foxidrive » 08 Dec 2014 06:11

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.

frostedflakes
Posts: 9
Joined: 06 Dec 2014 16:37

Re: new to batch scripting

#5 Post by frostedflakes » 08 Dec 2014 15:13

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..

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: new to batch scripting

#6 Post by Squashman » 08 Dec 2014 16:49

Can we see the path variable please.

frostedflakes
Posts: 9
Joined: 06 Dec 2014 16:37

Re: new to batch scripting

#7 Post by frostedflakes » 08 Dec 2014 16:57

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.

ShadowThief
Expert
Posts: 1167
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: new to batch scripting

#8 Post by ShadowThief » 08 Dec 2014 17:24

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.

frostedflakes
Posts: 9
Joined: 06 Dec 2014 16:37

Re: new to batch scripting

#9 Post by frostedflakes » 08 Dec 2014 19:15

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...

ShadowThief
Expert
Posts: 1167
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: new to batch scripting

#10 Post by ShadowThief » 08 Dec 2014 20:06

What you want is possible. Try using start instead of call.

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.

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: new to batch scripting

#11 Post by Squashman » 08 Dec 2014 20:24

I asked to see the system path variable that you said you changed.

frostedflakes
Posts: 9
Joined: 06 Dec 2014 16:37

Re: new to batch scripting

#12 Post by frostedflakes » 09 Dec 2014 01:29

for System Variable, I added C:\mtn-200808a-win32\mtn-200808a-win32\; to the end of the variable name PATH.

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: new to batch scripting

#13 Post by Squashman » 09 Dec 2014 08:24

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.

ShadowThief
Expert
Posts: 1167
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: new to batch scripting

#14 Post by ShadowThief » 10 Dec 2014 08:04

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%

frostedflakes
Posts: 9
Joined: 06 Dec 2014 16:37

Re: new to batch scripting

#15 Post by frostedflakes » 10 Dec 2014 21:25

Please post the entire output of

Code: 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;

Post Reply