Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I want to use automator to create a project folder with a Automator service, but i like to add the month and year (with two decimals) not the day, month and whole year.

want i can creatie is item_29022014 but i like to create a file named: 'item_0214' where the first two numbers (02) are the month and the last two numbers (14) are the last to numbers of the current year(2014).

Can i download some add-on for automator? Or do i need a custom script for this?

enter image description here

share|improve this question
    
I am confused, try again. Is that a part of file name? –  Buscar웃 Feb 13 at 19:37
    
i cant explain my self better then this. –  mvaneijgen Feb 13 at 19:42
    
great job, it is clear now. –  Buscar웃 Feb 13 at 20:07

1 Answer 1

Check the answer found here

https://apple.stackexchange.com/questions/52535/clean-up-file-names-using-automator

I changed the bash script code to include the date code.

shopt -s extglob
dcode=`date '+%m%y'`
for f in "$@"; do
   f1="${f%.*}"
   f2="${f##*.}"
   if [ "$f2" == "$f1" ] ; then     
       echo "$f" "${f1}_${dcode}"
   else
       echo "$f" "${f1}_${dcode}.${f2}"
   fi
done

The code will should work even with files that do not have extensions.

Replace the commands echo with mv to actually get the code to do anything.

Hope that helped.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.