I’m new to scripting and need a quick solution to a problem.
I’m using shake to composite some .dpx files, but the .dpx files that are on the server are all named in a timecode format that isn’t shake friendly, therefore shake won’t recognize them and bring them in sequentially as a single movie file. What script can I use to batch rename each file in a sequence:
They’re staying in the same server location, but saved just to a different folder. I’m not changing the format at all, they’re .dpx (video) files and they’ll remain .dpx. Is that what you’re asking? The server name on which they reside is called Xserve1 and it’s under a series of folders, but due to the confidetiality of intellectual properties I’m not at liberty to say what the folder names are specifically. I’m really new at this whole thing, I’m mostly a gui guy. Hope that’s what you’re looking for.
here is an example of a script which does such a job.
set thePath to "Xserve 1:path:to:folder:"
tell application "Finder" to set theItems to every document file of alias thePath whose name extension is "dpx"
repeat with i in theItems
set {filename, ext} to {name, name extension} of (info for (i as alias))
set filename to text 1 thru ((offset of "." in filename) - 1) of filename
-- your code to rename the files goes here
-- the result is in variable newName
tell application "Finder" to set name of i to newName & "." & ext
end repeat
Oh, I apologize. The sequence that the files are in now are named by the time code e.g.
P-10 HHMMSSFrame#.dpx
They need to be renamed to the sequence in my first post e.g.
vis_vfx1_1-001.dpx
vis_vfx1_1-002.dpx
etc.
Therefore, if I understand the script correctly, I would input it as follows:
set thePath to "Xserve 1:path:to:folder:"
tell application "Finder" to set theItems to every document file of alias thePath whose name extension is "dpx"
repeat with i in theItems
set {P-10 HHMMSSFrame#.dpx} to {vis_vfx1.1-001} of (info for (i as alias))
set filename to text 1 thru ((offset of "." in filename) - 1) of filename
-- your code to rename the files goes here
-- the result is in variable newName
tell application "Finder" to set name of i to newName & "." & ext
end repeat
Does this script also specify where the new destination folder will be?
Again, I really appreciate your taking your time to help me understand this scripting.
unfortunately it’s a bit more complicated.
I assume that the #-sign stands for a consecutive number which can be multi-digit.
This script duplicates every .dpx-file of source folder to destination folder and renames
the files for example "P-10 HHMMSSFrame1.dpx " as “vis_vfx1_1-001.dpx” and "P-10 HHMMSSFrame2.dpx " as “vis_vfx1_1-002.dpx”
and so on.
set sourcePath to "Xserve 1:path:to:source:"
set destPath to "Xserve 1:path:to:destination:"
tell application "Finder" to set theItems to every document file of alias sourcePath whose name extension is "dpx"
repeat with i in theItems
set {filename, ext} to {name, name extension} of (info for (i as alias)) -- extracts filename and extension
set nameOnly to text 1 thru ((offset of "." in filename) - 1) of filename -- removes the extension from filename
set frame_number to text ((offset of "Frame" in nameOnly) + 5) thru -1 of nameOnly -- extracts frame number from filename
set frame_number to text -3 thru -1 of ("00" & frame_number) -- adds leading zeros to frame number
set newName to "vis_vfx1.1-" & frame_number
tell application "Finder"
duplicate i to destPath as alias
set name of (destPath & filename as alias) to newName & "." & ext
end tell
end repeat
Model: G5 dual 2,5 GHz
Browser: Safari 419.3
Operating System: Mac OS X (10.4)