OT: Renaming folder items with folder name

Posted by strypes 
OT: Renaming folder items with folder name
July 23, 2010 08:24AM
Okay, I have a drive full of image sequences that I need to convert to QT files. I can import them and batch the image sequences in AE, but the catch is that the name of the clips are on the folder instead of the file. In Automator, I can do a find and replace by copying the folder name and replacing "frame" to the file name, and run it for all files within a folder. But I have some 200 folders, and renaming them folder by folder will drive me nuts. Does anyone know of any automator actions that can copy the name of the folder and replace a specified text with the name of its folder?



www.strypesinpost.com
Re: OT: Renaming folder items with folder name
July 24, 2010 05:43AM
Hi Gerard,

I'm not sure what you want to do. Could you explain it with an example.

Regards
Andreas

Some workflow tools for FCP [www.spherico.com]
TitleExchange -- juggle titles within FCS, FCPX and many other apps.
[www.spherico.com]
Re: OT: Renaming folder items with folder name
July 24, 2010 10:58PM
i think its that there are a bunch of image sequences in individually named folders,
such as "Shot 01" "Shot 02" etc.

the files in each folder are all named frame_01, frame_02, frame_03 etc regardless of the folder

G wants the files to be renamed to match the folder name:

shot01_01
shot01_02
shot01_03

and

shot02_01
shot02_02
shot02_03

etc.

ALTERNATE SOLUTION:

im assuming from this that AE reads the fle names and uses that for the image sequence name.
if it only uses the name of the FIRST file,
then it would only need a very simple QuickKeys macro to copy the folder name to the first file in each folder.
(applying the name to ALL files might be equally as simple, but my programming skills are neanderthal to say the least.)

OR:
is there some way for AE to pick up the folder name and use that when batching the image sequences?


nick
Re: OT: Renaming folder items with folder name
July 25, 2010 05:44AM
Okay, I got that done manually. How do you do it with Quickkeys? I couldn't find a way to get that done purely by keystrokes, without having a script somewhere.

What happened, was they converted a bunch of cine files into tiff sequences, but I got this instead:

"<clip name>/frame_0001" as opposed to "<clip name>_0001"

It's workable, just that when you have a few hundred clips, the renaming will take you about an hour or two.

Batch converting all of that into QT movies isn't a problem. In AE you need to select the first file, to import an image sequence, and the clip will take on the name of the file. You can rename the clip in the output module, but still that is a lot of manual clicking.

With Applescripts, I've only gotten so far:

on adding folder items to thisFolder after receiving droppedFolders
repeat with aFolder in droppedFolders

tell application "Finder" to set theSequence to (get first file of aFolder as alias)

tell application "QuickTime Player"
activate
open image sequence theSequence frames per second 25

set nameSequence to (theSequence as string) & ".mov"

tell document 1
with timeout of 500 seconds
save in file nameSequence
end timeout

close

end tell

end tell
end repeat
end adding folder items to


That is a folder action that will save the file as a reference QT movie based on the name of the first clip, and it is batchable. I'm trying to see how to insert an option to save the file to a specific location, add a few renaming options and to save that thing as a droplet.



www.strypesinpost.com
Re: OT: Renaming folder items with folder name
July 25, 2010 08:18AM
Gerard,

What your AppleScript does is just the opposite of what Nick said.
It does use the image name instead of the folder name. Also what does
Quote

<clip name>/frame_0001" as opposed to "<clip name>_0001"
mean. Is it a file path someFolder:frame_0001 or is it a fileName.
So I'm still a bit confused about what you want to do.

The decision for the AppleScript way is definitively better and faster than the AE approach.

I haven't done a lot with plain AppleScript for quite long time, but here one with allows you to select a Volume (or a folder with sub-folders), than it will list all folders on the first level, then list and check the contents of these folder for image files. These image files will added to a list for QT Player and from there the ref movie will be saved to the original folder they come from with the name of the folder.

Maybe you can take parts of it to make it fit for you.

Quote

property theFPS : "25"
property fileExtensionList : {"tif", "png", "tga", "jpg"}

property folderList : {}
property fileList : {}
property qtPlayerList : {}


set theVol to choose folder

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"
close every document without saving
repeat with seqItemPath in my qtPlayerList
set pathList to every text item of seqItemPath
set savePath to (items 1 thru -2 of pathList) as string -- that's the path to the original folder, the mov should be saved there, it's safer
set saveName to (item -2 of pathList) & ".mov" as string -- that's the name of the folder
set savePath to {savePath, saveName} as string

set seqMovie to open image sequence seqItemPath frames per second theFPS
save seqMovie in savePath
close document 1
end repeat
end tell
set AppleScript's text item delimiters to oldDelimiters

Regards
Andreas

Some workflow tools for FCP [www.spherico.com]
TitleExchange -- juggle titles within FCS, FCPX and many other apps.
[www.spherico.com]
Re: OT: Renaming folder items with folder name
July 25, 2010 10:29AM
Thanks, Andreas. I haven't had a good excuse to get into AppleScripts, and aside from creating the "hello, world" application, I am still trying to figure my way around.

Okay, I kinda see what you are doing- you create some sort of list, then get QT to open those files and apply information from those lists.

When I tried to compile your script, I got an "expected end of line, but found identifier" on this line for "sequence":

Quote

set seqMovie to open image sequence seqItemPath frames per second theFPS


I'm hoping to get the reference movies to a specific directory location so I can batch convert them for editing, then link them up for the conform.

>Is it a file path someFolder:frame_0001 or is it a fileName.

Pretty what Nick said earlier. I was getting the name of the shots in the folder instead of on the images, so I couldn't get AE to render out QT movies.


In getting my hands wet on this job, I realized that there are quite some issues dealing with image sequences in FCP- you can't easily conform back to the image sequences for finishing, partly because FCP doesn't ingest image sequences natively, and also they don't necessarily have timecodes (that also means audio sync is done manually). Apple's solution to ingesting dpx and cineon files is to go through Color, but knowing how Color stores and names render files, it may make for a very problematic online. That is not to mention you need Color 1.5, because earlier versions of Color don't register reel names, so you can't export a reliable EDL from Color.



www.strypesinpost.com
Re: OT: Renaming folder items with folder name
July 25, 2010 10:57AM
Hi Gerard,

I've no idea why it doesn't compile at your end. I've put the script (as app) on my website:
http:/www.spherico.com/filmtools/strypes/imageStrypes.zip

Let me know if it still doesn't work.

And yes - the handling of image sequences within FCP is not one of the shiny features.

Regards
Andreas

P.S. What version of FCP do you use?

Some workflow tools for FCP [www.spherico.com]
TitleExchange -- juggle titles within FCS, FCPX and many other apps.
[www.spherico.com]
Re: OT: Renaming folder items with folder name
July 25, 2010 11:06AM
strypes Wrote:
-------------------------------------------------------
> When I tried to compile your script, I got an
> "expected end of line, but found identifier" on
> this line for "sequence":

Might be an issue with copying + pasting from a webpage. Have you tried deleting the end of line character (i.e. so that the next line begins exactly where the previous one ends) and then pressing Enter to create a new line?

My software:
Pro Maintenance Tools - Tools to keep Final Cut Studio, Final Cut Pro X, Avid Media Composer and Adobe Premiere Pro running smoothly and fix problems when they arise
Pro Media Tools - Edit QuickTime chapters and metadata, detect gamma shifts, edit markers, watch renders and more
More tools...
Re: OT: Renaming folder items with folder name
July 25, 2010 11:40AM
I'm on FCP7, leopard. At work these days, I'm on FCP 6, tiger.

Thanks for the app, Andreas. Don't know what happened earlier, but specifying "Quicktime 7" means it ends up asking you which app that is. I sorta tweaked it a bit so I can specify save location, but it's saving one directory level higher than its supposed to.

EDIT: Okay. I read what Andreas wrote about 10.5 and earlier.

Quote

property theFPS : "25"
property fileExtensionList : {"tif", "png", "tga", "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" -- if you're running 10.5 or less it should be "QuickTime Player"
close every document without saving
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

set seqMovie to open image sequence seqItemPath frames per second theFPS
save seqMovie in savePath
close document 1
end repeat
end tell
set AppleScript's text item delimiters to oldDelimiters

Okay, I tried to add a display dialog to alter the frame rate, and I ended up getting 15 fps. This could be a very useful tool, if we can allow options to save as self contained, and to toggle between naming by file name or folder name. But my every touch in Applescript seems to freak it out.



www.strypesinpost.com
Sorry, only registered users may post in this forum.

Click here to login

 


Google
  Web lafcpug.org

Web Hosting by HermosawaveHermosawave Internet


Recycle computers and electronics