This is probably quite simple scripting but a little too much for me! I am after something to do this with applescript.
I have enormous directories of image sequences, scanned from a film scanner. When there is a gap in the frame numbering it means there is a new shot. What I need is a script that scans the list, and then each time it hits a gap in frame numbering it does an action. That action is to move all consecutive files before it into a new directory. Ideally the new directory created would reference the name of the first file in it. So a list like…
assuming that all name extensions consist the dot and 3 characters (.xxx) and the filename without extension is a number (as string)
try this:
set theFolder to choose folder
tell application "Finder"
set theList to (get every file of theFolder)
set theIndex to 0
repeat with i in theList
set fName to text 1 thru -5 of (get name of i)
if (theIndex is not (fName as integer)) then
try
set currentFolder to (make new folder at theFolder with properties {name:fName})
end try
set theIndex to (fName as integer) + 1
else
set theIndex to theIndex + 1
end if
move i to currentFolder
end repeat
end tell
in this case the script won’t work and throws an error.
If the raw-files begin always with raw., we can filter this out.
But: the files in one folder must be either with the “raw” prefix or without,
otherwise the order probably get confused. The extension doesn’t matter, if the length doesn’t differ
set theFolder to choose folder
tell application "Finder"
set theList to (get every file of theFolder)
set theIndex to 0
repeat with i in theList
set fName to text 1 thru -5 of (get name of i)
if fName begins with "raw." then set fName to text 5 thru -1 of fName
if (theIndex is not (fName as integer)) then
try
set currentFolder to ((theFolder as Unicode text) & fName) as alias
on error
set currentFolder to (make new folder at theFolder with properties {name:fName})
end try
set theIndex to (fName as integer) + 1
else
set theIndex to theIndex + 1
end if
move i to currentFolder
end repeat
end tell