Help with Automator

Discussion in 'Mac Programming' started by rei101, Apr 1, 2014.

  1. rei101 macrumors 6502a

    Joined:
    Dec 24, 2011
    #1
    Hello

    I know many people are avery smart and can help me out.

    I rendered like 300 videos with the wrong aspect ratio, instead of 4:3 they are 16:9.

    Now, I have all those videos in one folder and I have a software that can convert them but the software does not run batch. So I have to use automator to convert each file at a time.

    I can make automator to do one file but not the next file. All the videos are numbered from 0001 to 0300, and I need automator to go from 0001 to 0002 and so on. From one folder and save in another folder.

    How can I do that?

    Thank you.
     
  2. kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #2
    What software are you using to convert? Can you post a screenshot of your workflow? Automator has a loop action you could use together with the Dispense Items Incrementally action.

    Example use : Individually Looping Through Files in an Automator Workflow
    Download Dispense Items Incrementally action : http://automator.us/leopard/downloads/pkg/dispenseitemsincrementally/actioninstaller.zip
     
  3. rei101 thread starter macrumors 6502a

    Joined:
    Dec 24, 2011
    #3
    Mpeg Streamclip

    What I am doing is opening one video, changing the aspect ration and saving it in another folder, that is it. Over and over again.

    Thank you!
     
  4. rei101 thread starter macrumors 6502a

    Joined:
    Dec 24, 2011
    #4
    Well, I am building my workflow actually, is my first time using automator.

    I have downloaded the pluging you suggested. Now I would like to make Automator to open specific application (or to leave it open) and import the video file, change the aspect, save the video file and then open another video file.

    The thing is that I was doing a huge batch render at the office and the aspect was wrong and now I have to redo everything and mpeg streamclip does it really fast but only one file at a time.
     
  5. kryten2, Apr 1, 2014
    Last edited: Apr 2, 2014

    kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #5
    I downloaded Mpeg Streamclip v 1.9.2. Looking at the file menu I see a lot of exporting and converting options but nothing related to changing aspect ratio. In the list menu there's a Batch List menu item. Isn't this what you said it did not run? Can't you use this Batch List to change aspect and save. The appliction has no Applescript dictionary or Automator actions so the only thing you can do in Automator is opening some file then do your stuff in the Mpeg Streamclip application like it seems you're doing now. There's always GUI scripting as a last resort to turn to. A quick Google search looks promising. As it is your first time using Automator I'm afraid GUI scripting is a little bit harder. However I'm willing to help if you provide a screenshot of Mpeg Streamclip where I can find something to change aspect ratio and some info on what kind of files you're opening eg what kind of file extension and in what format you're saving them.

    Info : Applescript for MPEG Streamclip and Applescript/Automator help

    Example of Applescript GUI script :

    Code:
    -- Choose a source folder with files in to process
    set sourceFolder to choose folder with prompt "Choose folder with your 16:9 aspect ratio files to process." default location path to movies folder
    
    -- Choose a destination folder to save processed files to
    set destinationFolder to choose folder with prompt "Choose folder where to save the fixed 4:3 aspect ratio files to." default location path to movies folder
    
    -- Make list of files in folder sourceFolder that have a "mov" extension. If extension is different then change!
    tell application "Finder" to set myFiles to files of folder sourceFolder whose name extension is "mov"
    
    -- Loop through files from list
    repeat with i from 1 to count of myFiles
    	set aFile to item i of myFiles
    	-- Open file in "MPEG Streamclip"
    	tell application "Finder" to open aFile using application file "MPEG Streamclip.app" of folder "Applications" of startup disk
    	-- Delays to not let the script trip. If not sufficient then increase eg delay 1
    	tell application "MPEG Streamclip" to activate
    	delay 0.5
    	tell application "System Events"
    		tell process "MPEG Streamclip"
    			click pop up button 1 of window "MPEG Streamclip 1.9.2 © 2004-2008 Squared 5 "
    			click menu item "4:3" of menu 1 of pop up button 1 of window "MPEG Streamclip 1.9.2 © 2004-2008 Squared 5 "
    			delay 0.5
    			keystroke "s" using {command down}
    			delay 0.5
    			-- For the first file in the loop, set the destination path in the popup sheet.
    			-- For all the other files just click the save button.
    			if i < 2 then
    				keystroke "g" using {command down, shift down}
    				delay 0.5
    				keystroke destinationFolder
    				delay 0.5
    				click button "Go" of sheet 1 of window "Create New MOV File"
    				delay 0.5
    			end if
    			-- Save the file. Input was MOV file, output also MOV file.
    			click button "Save" of window "Create New MOV File"
    			delay 0.5
    			-- Loop until the "MPEG Streamclip" dialog/progress window no longer exists 
    			repeat while (exists window "MPEG Streamclip")
    			end repeat
    			delay 0.5
    			-- Close the file
    			keystroke "w" using {command down}
    		end tell
    	end tell
    end repeat
     
  6. rei101 thread starter macrumors 6502a

    Joined:
    Dec 24, 2011
    #6
    You would have to download the beta version 1.9.3b8 just right below the version you downloaded. Under EDIT menu, you can find ASPECT RATIO. I hav eto run to my office. Thank you!
     
  7. kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #7
    Didn't receive all the answers to my questions. Anyway here's an example of Applescript GUI script for MPEG Streamclip v1.9.3b8 :

    Code:
    -- Choose a source folder with file in to process
    set sourceFolder to choose folder with prompt "Choose folder with your 16:9 aspect ratio files to process." default location path to movies folder
    
    -- Choose a destination folder to save processed files to
    set destinationFolder to choose folder with prompt "Choose folder where to save the fixed 4:3 aspect ratio files to." default location path to movies folder
    
    -- Make list of files in folder sourceFolder that have a "mov" extension. If extension is different then change!
    tell application "Finder" to set myFiles to files of folder sourceFolder whose name extension is "mov"
    
    -- Loop through files from list
    repeat with i from 1 to count of myFiles
    	set aFile to item i of myFiles
    	-- Open file in "MPEG Streamclip"
    	tell application "Finder" to open aFile using application file "MPEG Streamclip.app" of folder "Applications" of startup disk
    	-- Delays to not let the script trip. If not sufficient then increase eg delay 1
    	tell application "MPEG Streamclip" to activate
    	delay 0.5
    	tell application "System Events"
    		tell process "MPEG Streamclip"
    			-- For use with MPEG Streamclip 1.9.2
    			--click pop up button 1 of window "MPEG Streamclip 1.9.2 © 2004-2008 Squared 5 "
    			--click menu item "4:3" of menu 1 of pop up button 1 of window "MPEG Streamclip 1.9.2 © 2004-2008 Squared 5 "
    			-- For use with MPEG Streamclip 1.9.3b8
    			click menu item "4:3" of menu 1 of menu item "Aspect Ratio" of menu 1 of menu bar item "Edit" of menu bar 1
    			delay 0.5
    			keystroke "s" using {command down}
    			delay 0.5
    			-- For the first file in the loop, set the destination path in the popup sheet.
    			-- For all the other files just click the save button.
    			if i < 2 then
    				keystroke "g" using {command down, shift down}
    				delay 0.5
    				keystroke destinationFolder
    				delay 0.5
    				click button "Go" of sheet 1 of window "Create New MOV File"
    				delay 0.5
    			end if
    			-- Save the file. Input was MOV file, output also MOV file.
    			click button "Save" of window "Create New MOV File"
    			delay 0.5
    			-- Loop until the "MPEG Streamclip" dialog/progress window no longer exists 
    			repeat while (exists window "MPEG Streamclip")
    			end repeat
    			delay 0.5
    			-- Close the file
    			keystroke "w" using {command down}
    		end tell
    	end tell
    end repeat
    
    Note : Run the script in AppleScript Editor! Best not to do anything else while the script runs!
     
  8. rei101 thread starter macrumors 6502a

    Joined:
    Dec 24, 2011
    #8
    (y), you are amazing, thank you.
     

Share This Page