Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Batch renaming files using metadata pulled from ffmpeg

I'm an absolute beginner trying to build a droplet (out of an existing droplet) that will let me drag a video file onto it, and rename that file with the frame rate before the extension. ie: TEST.mp4 drag to droplet TEST2997.mp4

I have absolutely no idea what I'm doing and most of this code is from another ffmpeg droplet I found. Any help or direction at all would be much appreciated.


Heres the nonfunctional code I have so far:







global fileName

global outputName




to split(someText, delimiter)

set AppleScript'stext item delimiters to delimiter

set someText to someText'stext items

set AppleScript'stext item delimiters to {""}

return someText

end split




on opennames



set ffmpeg to "ffmpeg"


set afterEncoding to "open .; afplay \"/System/Library/Sounds/Glass.aiff\"; "

set afterEncoding to afterEncoding & "echo \"Success!
Saved to same folder as original.\""




repeat with itemnum from 1 to count of names



-- inputPath: absolute path to file

set inputPath to POSIX path of (itemitemnum of names)



-- fileParent: absolute path to file's parent folder

tell application "Finder"

set fileParent to inputPath

set AppleScript'stext item delimiters to "/"

set fileParent to text items 1 thru -2 of fileParent as text

set fileParent to fileParent & "/"

end tell







-- fileName: file's name without extension

set extension to ""

set fileName to ""

tell application "Finder"

set inputName to name of file (itemitemnum of names)

set fileName to inputName

set AppleScript'stext item delimiters to "."

if number of text items of fileName > 1 then

set extension to text item (count of text items of fileName) of fileName as text

set fileName to text items 1 thru -2 of fileName as text

end if

end tell


set str to ffmpeg & " -i \"" & inputPath & "\" 2>&1 | sed -n \"s/.*, \\(.*\\) fp.*/\\1/p\""

set fpsInput to do shell scriptstr

set fpsInput to fpsInput as number




set outputName to fileName & fpsInput & "." & extension

set outputPath to fileParent & outputName



if checkExist(outputPath) then

tell application "Terminal"


do script "cd \"" & fileParent & "\"; " & ffmpeg & " -i '" & inputName & "' -c:v copy -c:a copy '" & outputName & "'; " & afterEncoding

end tell

end if


end repeat

return

end open

iMac

Posted on May 25, 2018 1:56 PM

Similar questions

1 reply

There are no replies.

Batch renaming files using metadata pulled from ffmpeg

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.