applescript to re-name files

Discussion in 'Mac Basics and Help' started by i.shaun, Nov 7, 2008.

  1. i.shaun macrumors 6502a

    i.shaun

    Joined:
    May 1, 2008
    Location:
    Canada
    #1
    How do I write an apple script to attach to a particular folder that will:

    -re-name files in order as they arrive to a number "0001" "0002" or, just attach the number to the beginning of the current file name.



    I tried reading some stuff on apple script, but It seems very confusing to me. I Like using them, especially the iTunes ones I have found. I just don't know how to properly write one.
     
  2. i.shaun thread starter macrumors 6502a

    i.shaun

    Joined:
    May 1, 2008
    Location:
    Canada
    #2
    Alright, how about some script help here. I tried the "Record" feature to get something to go off of.

    It says:

    set name of document file "file.jpg"....

    ..to "0001_file.jpg"



    ---------------------
    How do I:

    -make it set name of most recently added file (this will be a folder action after all)
    -set a sequence of numbers that it can add to the files as they come (ie: 0001_file.jpg 0002_file.jpg, etc..)

    ----------------------------

    I'm trying but I can't seem to get these commands to work as I'm basically guessing what commands do what, or even work at all for that matter. The sequence seems to be the most complex part, there has to be some special code for that.
     
  3. i.shaun thread starter macrumors 6502a

    i.shaun

    Joined:
    May 1, 2008
    Location:
    Canada
    #3
    So far I got:
    ------------
    tell application "Finder"
    activate
    set prefix of document files of folder "C&H" of folder "Photos" of folder "Files" of folder "Shaun" of folder "Users" of startup disk to "ThisPartWorks_"
    end tell

    -------------
    Finder Got an error: can't set prefix of every document file of folder "C&H" of folder "Photos" of folder "Files" of folder "Shaun" of folder "Users" of startup disk to "ThisPartWorks_"

    --------


    I wanted to change the prefix of the one file I have in there to that, so I can confirm the first part of the script works. Then I was going to move on to the number sequence thing.
     

Share This Page