Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Applescript Help (I know its bad)

Options
  • 06-07-2015 1:30am
    #1
    Registered Users Posts: 263 ✭✭


    Hi Guys,

    Im trying to come to grips with apple scripting and cannot get my head around it (I can code in java, no problem... go figure) Anyway, what i am trying to do is sort out my downloads folders automatically and move files based firstly on their extension and then move them to folders based on the name. I have written out the pseudo code and feel like I'm running into a brick wall... Anyone proficient in apple scripting care to fill in the code?

    -- GO TO FINDER AND OPEN THE DOWNLOADS FOLDER

    -- LIST ALL FILES WHICH END WITH THE VIDEO EXTENSION ".mpg , .avi , .mkv , .mp4"

    -- GET THE NAME OF EVERY FILE LISTED ABOVE

    -- IF THE FILENAME CONTAINS S**E**

    -- COPY THE FILE

    -- GO TO TV SHOW FOLDER (MOUNTED DRIVE)

    -- SEARCH FOR FOLDER WITH THE NAME OF THE FILE ABOVE

    -- IF FOLDER EXISTS GO INTO FOLDER

    -- GET THE S** AND SEARCH FOR FOLDER

    -- IF FOLDER EXISTS EXISTS GO INTO FOLDER

    -- PASTE FILE THERE

    -- ELSE CREATE FOLDER "SEASON" + ** FROM FILE

    -- GO INTO CREATED FOLDER

    -- PASTE ITEM IN FOLDER

    -- CLOSE FINDER

    -- ELSE CREATE FOLDER "PREFIX BEFORE S**" FROM FILE

    -- GO INTO CREATED FOLDER

    -- CREATE FOLDER "SEASON" + ** FROM FILE

    -- GO INTO CREATE FOLDER

    -- PASTE ITEM

    -- CLOSE FINDER

    -- ELSE IF FILENAME "YYYY"

    -- GO TO MOVIE FOLDER

    -- GO TO FOLDER "YYYY"

    -- PASTE ITEM

    -- CLOSE FINDER


Comments

  • Registered Users Posts: 6,041 ✭✭✭Talisman


    Any particular reason you want to do this in AppleScript? It would be easy enough to do in Python and chances are there is already such a script published for users of Plex / Kodi.


  • Registered Users Posts: 263 ✭✭dpjmie


    Talisman wrote: »
    Any particular reason you want to do this in AppleScript? It would be easy enough to do in Python and chances are there is already such a script published for users of Plex / Kodi.

    I just presumed it would be easier to do in applescript as its native... I managed to get it done but then messed it up and deleted it... If i get it done ill post a link to it

    Cheers for the recommendation

    Dpjmie


  • Registered Users Posts: 6,041 ✭✭✭Talisman


    Native it may be but I always found it to be a PITA to use. Python 2.7 is pre-installed on the system so you can use it to create your own shell scripts.

    How are you acquiring your content? Sick Beard may perform the task that you want. It's been a few years since I have actively used it for a media centre PC but I do remember that it could rename files and move them to folders for Plex/XBMC after the download had completed.


  • Registered Users Posts: 263 ✭✭dpjmie


    Talisman wrote: »
    Native it may be but I always found it to be a PITA to use. Python 2.7 is pre-installed on the system so you can use it to create your own shell scripts.

    How are you acquiring your content? Sick Beard may perform the task that you want. It's been a few years since I have actively used it for a media centre PC but I do remember that it could rename files and move them to folders for Plex/XBMC after the download had completed.

    I am acquiring my content using torrents and magnet links (I know i shouldn't but hey) and I've glanced at sick beard before but never really gave it too much thought...


  • Registered Users Posts: 8,615 ✭✭✭squonk


    I do this on my system. I considered writing scripts to do this for a while but, looking down the line, maintainability and turnaround times were just not what I wanted for a leisure system. I don't want to spend half my evening coding, debugging and testing scripts for a quick change. In the end I opted for a tool called Hazel which allows you to specify rules to move files based on type, name and many other attributes. What's more, you'll find plenty of rules out there designed to do what you want. You'll just need a few minutes to customise them for your own environment.

    For instance, you can find rules that parse the series name based on S and E attributes and clean up the series name e.g rename My.Hot.Show to My Hot Show, then go to your mounted drive and if a folder for My Hot Show doesn't exist, create it and create a subfolder Season 1 and place the file in there. PM me if you want to go the Hazel route. I can help you get started.


  • Advertisement
Advertisement