I have used the automator script to rename a big bunch of photos in the format YYYYMMDD filename.xxx, automator does not give the option of changing the name in YYYYMM filename.xxx, do you have any suggestion of small script to get to YYYYMM filename.xxx?

I was going to suggest dropping the Today's date variable into the Rename/Add Text action and edit the format, but that doesn't work either, so you can give the following Run AppleScript a try:

Code:

on run {input, parameters}
set output to {}
tell ((current date) as «class isot» as string) to set myDate to text 1 thru 4 & text 6 thru 7
tell application "Finder" to repeat with anItem in the input
set anItem to contents of anItem
set name of anItem to myDate & space & name of anItem
set end of output to anItem
end repeat
return output
end run

Since you are talking about pictures, if you are comfortable with the command line, this program uses the data stored by the camera (EXIF) to change the filename, etc. and you can make your own format.

This is why no one uses Automator that much - Apple just doesn't pay any attention to it at all. The Get Specified Finder Items action says it passes Finder Items to the next action, but it actually passes POSIX paths, which the Finder can't use. The following Run AppleScript action will convert the input to aliases, which the Finder knows about (System Events can also be used, but the terminology changes depending on if it is a POSIX path or an alias):

Code:

on run {input, parameters}
set output to {}
tell ((current date) as «class isot» as string) to set myDate to text 1 thru 4 & text 6 thru 7
tell application "Finder" to repeat with anItem in the input
set anItem to anItem as text
if anItem begins with "/" then set anItem to anItem as POSIX file
set anItem to anItem as alias
set name of anItem to myDate & space & name of anItem
set end of output to anItem
end repeat
return output
end run

Hmmm, hadn't even noticed that! My original script was tested using the Ask for Finder Items, but I had it fail using the Get Specified Finder Items action for the mentioned reason. Automator is still goofy, though.

Notice that in your attached tumbnail your Run Applescript does nothing but returning the input. The rest of the script is commented out.

Mate thanks for pointing that out, the script did work but put the today's date where I wanted to put the creation date. Tried putting in the script creation date but it does not work. Any other suggestion?

Yes current date in Applescript is today's date. Do you mean the creation date of the files you're inputting? If so try this :

Code:

on run {input, parameters}
set output to {}
--tell ((current date) as «class isot» as string) to set myDate to text 1 thru 4 & text 6 thru 7
tell application "Finder" to repeat with anItem in the input
set anItem to anItem as text
if anItem begins with "/" then set anItem to anItem as POSIX file
set anItem to anItem as alias
set creationDate to creation date of anItem
tell ((creationDate) as «class isot» as string) to set myDate to text 1 thru 4 & text 6 thru 7
set name of anItem to myDate & space & name of anItem
set end of output to anItem
end repeat
return output
end run

Note : The creation date property of a Finder item is the date on which the item was created. If you want the date the photo was taken your best option would be to use the exiftool like neier suggested.