Skip to content

Instantly share code, notes, and snippets.

@milothiesen
Created March 1, 2016 03:18
Show Gist options
  • Save milothiesen/f32432114aa09d0d466a to your computer and use it in GitHub Desktop.
Save milothiesen/f32432114aa09d0d466a to your computer and use it in GitHub Desktop.
Final Cut Pro 7/ Premiere Pro CC XML Parser that allows you to automate media reconnecting/ relinking and removes Color Corrector 3-Way. Code can be modified to remove any individual video filter without effecting other video filters.
#CODE COMPILED BY MAILE THIESEN#
# vvv-----CODE AND IDEAS USED FROM THE FOLLOWING SOURCES-----vvv
# http://stackoverflow.com/questions/13825725/how-to-delete-an-xml-element-according-to-value-of-one-of-its-children
# Code derived from http://stackoverflow.com/questions/2096679/editing-text-in-a-nokogiri-element-or-using-regex
# http://stackoverflow.com/questions/1122115/how-to-parse-xml-files-with-nokogiri-and-put-the-results-in-a-new-file
# http://www.kenstone.net/fcp_homepage/xml_fcp_hodgetts.html
# PLACE THIS FILE IN THE DIRECTORY WHERE THE XML FILES EXIST. IT LOOKS FOR ALL FILES WITH THE .xml
# EXTENSION AND DOES TWO THINGS
# 1. IT CHANGES ALL PATHURLS, SO YOU CAN AUTOMATICALLY UPDATE THE PATHS FOR WHEN YOU MOVE MEDIA FROM ONE LOCATION TO ANOTHER.
# I AM ATTEMPTING TO USE THIS TO REDUCE THE AMOUNT OF TIME SPENT RECONNECTING MASS BATCHES OF FINAL CUT 7 FILES
# 2. THE SCRIPT LOOKS FOR THE 3 WAY COLOR CORRECTOR VIDEO EFFECT AND REMOVES IT WHILE LEAVING OHTER EFFECTS INTACT IN THE XML.
# I DECIDED IT WOULD BE BETTER TO REMOVE THESE THAN TO HAVE PREMIERE TRY TO INTERPERATE, BECAUSE IT LOOKS BAD.
# MODIFY THE CODE TO REMOVE ANY EFFECT OR TRANSITION YOU LIKE...
require 'nokogiri'
Dir.glob("*.xml").each do |filename|
# vvv-----USE THIS IF YOU WANT TO RUN THE SCRIPT ON AN INDIVIDUAL FILE-----vvv
# str = File.open('abstract-shape-reflection_Test.xml')
str = File.open(filename)
doc = Nokogiri::XML.parse(str)
for pathurl in doc.xpath('//pathurl/text()')
pathurl.content = pathurl.content.gsub("/localhost/Users/mailethiesen/Desktop/desktop", "/localhost/Users/mailethiesen/Documents")
end
doc.xpath("//effect[name='Color Corrector 3-way']").remove
# vvv-----USE THIS IF YOU WANT TO RUN THE SCRIPT ON AN INDIVIDUAL FILE-----vvv
# File.write('abstract-shape-reflection_Test.xml', doc.to_xml)
File.write(filename, doc.to_xml)
end
@milothiesen
Copy link
Author

Note to self: may want to use this Dir.glob("#{folder}/*/.pdf") to search all subfolders recursively. -http://stackoverflow.com/questions/3498539/searching-a-folder-and-all-of-its-subfolders-for-files-of-a-certain-type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment