Hello!
I’m a newbie to Applescript and this evening have written a script to sequence Jpgs and create an h264 mov file. All great! However, I’d love to have the script look at a folder and all subfolders within it for jpgs, and if found to sequence them. One addition would be for the script to look for a .mov in the folder with the Jpgs, and if present to skip that folder assuming that those Jpgs have already been sequenced.
Can someone help me with the repeat loops to search all the folders? I’ve had a stab but not getting anywhere.
Thanks!
Rob
You can change this easily for you jpeg searcher. It’s a simple example of getting files recursive.
getFolderContents(path to desktop as string)
on getFolderContents(ofFolder)
if ofFolder does not end with ":" then
set ofFolder to ofFolder & ":"
end if
set AppleScript's text item delimiters to return
set theContents to every text item of (do shell script "ls -F " & quoted form of POSIX path of ofFolder)
set AppleScript's text item delimiters to ""
set fullPaths to {}
repeat with anItem in theContents
if anItem ends with "/" then
if anItem ends with ".app/" then
set end of fullPaths to ofFolder & characters 1 thru -2 of anItem as string
else
set fullPaths to fullPaths & every item of getFolderContents(ofFolder & characters 1 thru -2 of anItem as string)
end if
else if anItem ends with "@" then
--don't follow symbolic links
else if anItem ends with "*" then
--the file is an executable
set end of fullPaths to ofFolder & characters 1 thru -2 of anItem as string
else if anItem ends with "=" then
--the file is an socket
--nothing we want to do with a socket right now
else if anItem ends with "%" then
--the file is a whiteout
--nothing we want to do with a whiteout right now
else if anItem ends with "|" then
--the file is an FIFO
--nothing we want to do with an FIFO right now
else
set end of fullPaths to ofFolder & anItem as string
end if
end repeat
return fullPaths
end getFolderContents
Thanks! That’s so helpful. I’ll try and get it going tonight. Below is the code I tried to get to work but it doesn’t do anything. It opens up QT but then doesn’t get QT to do anything. Nor does it error. I found a lot of the code on this site but then adapted and wrote bits myself, so presumably I’ve missed something out? What do you think?
quote
property theFPS : "25"
property fileExtensionList : {"jpeg", "jpg"}
property folderList : {}
property fileList : {}
property qtPlayerList : {}
set theVol to choose folder with prompt "Choose directory of image sequences"
set savefolder to choose folder with prompt "Choose save location, but will save one level higher"
tell application "Finder"
set tempFolderList to every folder of theVol
set my folderList to {}
repeat with theItem in tempFolderList
set thePath to theItem as string
set end of my folderList to thePath
end repeat
end tell
set my qtPlayerList to {}
repeat with theFolder in my folderList
set my fileList to list folder theFolder without invisibles
repeat with theFile in my fileList
set theFilePath to (theFolder & theFile) as string
set nameExtension to (name extension of (info for alias theFilePath))
if nameExtension is in fileExtensionList then
set end of my qtPlayerList to theFilePath
exit repeat
end if
end repeat
end repeat
set oldDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
tell application "QuickTime Player 7" -- if you're running 10.5 or less it should be "QuickTime Player"
activate
repeat with seqItemPath in my qtPlayerList
set pathList to every text item of seqItemPath
set savePath to savefolder
set saveName to (item -2 of pathList) & ".mov" as string -- that's the name of the folder
set savePath to {savePath, saveName} as string
open image sequence seqItemPath frames per second theFPS
with timeout of (30 * 60) seconds
export front document to savePath as QuickTime movie using most recent settings
end timeout
close document 1
end repeat
end tell
set AppleScript's text item delimiters to oldDelimiters