Automator/Apple script question...

neuby

Registered
Hi - not a developer here, although I have some rudimentary sripting experience.

Is it possible to have automator or applescript do the following:

Given a folder with numerous sub folders, and sub - sub folders, go to the file level on each, extract the name of the containing folder, then rename all contents sequentially?

IE I have thousands of image files saved in the following structure:

2005>Jan>Jan1

etc. (dang - this web text field won't let me space or tab properly). The year contains 12 month folders, each month contains several different day folders, and each of those contains image files with numeric names (pict002334.jpg) etc.

I would like to rename the files so that pict#####.jpg, etc becomes Jan 3-1.jpg, Jan 3-2.jpg etc.

I have written an automator script that will do this for a single folder, but it neither loops, nor parses the name of the folder - the user has to manually enter that. A slight help, but not nearly as usefull as a script that will do it with nested folders, and no user input.

Suggestions?

Any good applescript/automator sites you could refer me too? Anyone HAVE such a script??

ADVthanksANCE
 
'Is it possible to have automator or applescript do the following:

Given a folder with numerous sub folders, and sub - sub folders, go to the file level on each, extract the name of the containing folder, then rename all contents sequentially?' - yes, with 'Automator', or via an AppleScript script or applet.

'I would like to rename the files so that pict#####.jpg, etc becomes Jan 3-1.jpg, Jan 3-2.jpg etc.' - yes - this can be performed, with 'Automator', or via an AppleScript script or applet.
 
barhar said:
'Is it possible to have automator or applescript do the following:

Given a folder with numerous sub folders, and sub - sub folders, go to the file level on each, extract the name of the containing folder, then rename all contents sequentially?' - yes, with 'Automator', or via an AppleScript script or applet.

'I would like to rename the files so that pict#####.jpg, etc becomes Jan 3-1.jpg, Jan 3-2.jpg etc.' - yes - this can be performed, with 'Automator', or via an AppleScript script or applet.


First - thanks for replying. While encouraging, the reply is somewhat cryptic! Allow me to re-phrase.

Can you please tell me HOW to do this in automator? I see no way for automator to gather and parse string information from folders. Also, there does not seem to be a way to have it rename files within a folder without pausing for user input.

If you know of a tweak/hack workaround for the finder rename that will allow it to accept string input rather than user input, please tell me how.

Further to the above - how do you loop in automator? I don't see how to write an algorithim to do this (burrow into nested folders) without a controlled loop structure - and automator does not seem to have one.

Thanks!!
 
Currently, 'Automator' is top down programming only. You cannot branch upwards, to a perviously executed 'Action' or do a 'repeat' loop containing 'Actions'.
You can call an 'Automator' 'Run AppleScript' 'Action'. In the 'Run AppleScript' 'Action' you can use standard AppleScript code, including 'repeat' ... 'end repeat' loops.

To 'rename files' just have a string variable in the 'Automator' 'Run AppleScript' 'Action', where the looping through a folder's contents, and any sub folder(s) of that folder, from which to reference what name to rename the '.jpg' files. You could also have a text file somewhere which is opened and its contents becomes the staring name of the desired files. Or you could use AppleScript's own database methods.

As far as using 'Jan 3-1.jpg' - if assuming you want the current month followed by a space followed by the current day followed by '-' and then an incremental value, and finally the '.jpg' - one can use (something in the order of) ...

set nName to (month of (current date)) & " " & (day of (current date)) & "-" & tInc & '.jpg'

... where 'nName' is the new name for the file, and 'tInc' is the 'repeat' loops incremental variable name.

To loop through a folder's, folder's, folder's, etc. create a handler, which calls (recursion) itself if the current item (of a 'repeat' loop) of the current folder - is a folder.
 
Back
Top