Guest User

Untitled

a guest
Apr 22nd, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2. ::Converts mov files to mp4's that are compatible with i-devices (iPhone, iPad) and Android
  3.  
  4.  
  5. set WORKING_DIR="C:\Documents and Settings\Jordan.Sun\Desktop\temp\NBC"
  6.  
  7. cd WORKING_DIR
  8.  
  9. ::This is to make sure we don't run this script if another instance is already running. At the end of this script, we delete this temporary file.
  10. IF EXIST media.date (
  11.     goto :eof
  12. ) ELSE (
  13.     echo Process started at: >> media.date
  14.     gnudate >> media.date
  15. )
  16.  
  17. :: Finding any files modified more than 10 min ago but less than 2 days ago, then adding them to the file list that we parse and ftp if the file isn't being written to.
  18. :: "file.list" is of the form:
  19. :: FILENAME,FILESIZE
  20. IF NOT EXIST files.list (
  21.     FOR /F "tokens=*" %%A IN ('gnufind *.mp4 -mmin +10 -mtime -2 -print') do (
  22.         echo %%A,%%~zA >> files.list
  23.     )
  24.     goto :cleanup
  25. )
  26.  
  27. ::Check if the file size (%%~zA) has changed since the last time the script ran (%%B, which is the second column in the files.list file)
  28. ::If it hasn't changed, then the file isn't being written to so we convert it it, and then "delete" it from the list by writing it to a new temp "files.list" and deleting the original.
  29. ::If the file HAS changed, then we don't FTP it and keep it in files.list
  30. FOR /F "tokens=1,2 delims=, " %%A IN (files.list) do (
  31.     IF "%%B"=="%%~zA" (
  32.         echo Here's B: "%%B" and heres A: "%%~zA"
  33.         ffmpeg -i "%%A" -vcodec libx264 -sameq -maxrate 10000000 -bufsize 10000000 -vprofile baseline -level 30 -acodec libvo_aacenc "%%~nA.mp4"
  34.     ) ELSE (
  35.         echo %%A,%%~zA >> files.list2
  36.     )
  37. )
  38.  
  39. ::Here we "update" the files.list. If there are no more files (ie - no live events are going on), then files.list stays blank.
  40. del files.list
  41. IF EXIST files.list2 (
  42.     rename files.list2 files.list
  43. )
  44. goto :cleanup
  45.  
  46.  
  47. :cleanup
  48. del media.date
Add Comment
Please, Sign In to add comment