renaming files in reverse sequence

Hi,

I’d like to write a script but cant work out how. I want to rename all the files in a folder so that they list in reverse order. What I’m doing is breaking up QT movies into a series of sequenced jpegs (which is easily done)but then I want to reverse their order so I can stitch the animations back up to run ‘backwards’. Is someone able to help with that as I am totally new to the world of scripting?

Cheers

James

Hi jim,

you can reverse the order of a list by using ‘reverse of’.

Example:

set tFold to choose folder with prompt "Select the picture folder"
tell application "Finder"
set picList to (every file of tFold) as alias listend tellset revList to reverse of picList

regards

Hi Jim,

if you’re totally new to AS the thing you want to do is not so easy to explain…
if I understood well what you want to do the following code should work:

I guess you have all these QuickTime segment files in one folder, maybe on your desktop and they have names like segment01.mov, segment02.mov and so on.
So open the following code in ScriptEditor and save it as application (droplet) to your desktop. Now select all your QTsegment files, drag them on the application icon et voila!

on open myFiles
	set c to count of myFiles -- let's say "50"
	set i to 0 -- to create a counter
	tell application "Finder"
		repeat with aFile in myFiles
			set oldName to name of aFile -- for example "segment01.mov"
			set newName to ((c - i) as string) & oldName -- returns "50segment01.mov"
			set name of aFile to newName
			set i to (i + 1) -- "1"
		end repeat
	end tell
end open

At the end you should have 50 segment files, the first (which was the last) called “1segment50.mov” and the last one (which was the first) called “50segment01.mov”

Hope it works for you
Cheers
Farid