codyfromthe

Q: How to move documents due to name in AppleScript edit

So I've been trying to move documents due to name, from my desktop into a different folder in AppleScript edit but all my tries have managed to do nothing. If anyone can help that would be great.

Posted on Sep 12, 2016 1:08 AM

Close

Q: How to move documents due to name in AppleScript edit

  • All replies
  • Helpful answers

  • by Limnos,

    Limnos Limnos Sep 12, 2016 8:48 AM in response to codyfromthe
    Level 9 (53,936 points)
    Mac OS X
    Sep 12, 2016 8:48 AM in response to codyfromthe
  • by codyfromthe,Solvedanswer

    codyfromthe codyfromthe Sep 12, 2016 8:05 PM in response to Limnos
    Level 1 (4 points)
    Mac OS X
    Sep 12, 2016 8:05 PM in response to Limnos

    So how would you do this in applescript?

  • by Camelot,Helpful

    Camelot Camelot Sep 21, 2016 2:10 AM in response to codyfromthe
    Level 8 (47,285 points)
    Mac OS X
    Sep 21, 2016 2:10 AM in response to codyfromthe

    Your question is extremely vague - there are a gazillion and one different ways you might want to sort/filter the files, but in general you can start with something like:

     

    tell application "Finder"

      -- identify the files:

      set theFiles to (every file of (path to desktop))

      -- move them to some other location:

      move theFiles to folder "blah" of (path to home folder)

    end tell

     

    Once you have this you can refine/filter the list in whatever way you like. For example if you want files that begin with the letter 'a':

     

      set theFiles to (every file of (path to desktop) whose name begins with "a")

     

    Or maybe you want files that are jpeg's:

     

      set theFiles to (every file of (path to desktop) whose name extension is "jpg")

     

    Or any number of other variations you like.

  • by Limnos,

    Limnos Limnos Sep 14, 2016 10:44 AM in response to codyfromthe
    Level 9 (53,936 points)
    Mac OS X
    Sep 14, 2016 10:44 AM in response to codyfromthe

    codyfromthe wrote:

     

    So how would you do this in applescript?

    Did you read the topic I linked? It posts several examples of lines you could use in an Applescript, including shell scripting inside Applescript to make the process much faster in handling large numbers of files.  All you need do is copy the desired text to an Applescript Editor window, edit the criteria to meet your exact needs (which are not clear from your post), then save the script.

     

    By the way, did your second question, "So how would you do this in applescript?" solve your first question?

  • by codyfromthe,

    codyfromthe codyfromthe Sep 21, 2016 2:11 AM in response to Camelot
    Level 1 (4 points)
    Mac OS X
    Sep 21, 2016 2:11 AM in response to Camelot

    Thanks this helps a lot.