BestyGamesBestyGames
    What's Hot

    Top 10 apps to prevent food waste

    Advantages of Snaptube when Downloading Facebook Videos

    8 Best Apps to Remove Background from Images

    Facebook Twitter
    • About Us
    • Contact Us
    • Curation Policy
    • DMCA
    • Privacy Policy
    • Terms & Conditions
    Facebook Twitter
    BestyGamesBestyGames
    Contact Us
    • Home
    • Batman
    • Assassin’s Creed
    • Call of duty
    • Destiny
    • Final Fantasy
    • Resident Evil
    • Contact Us
    BestyGamesBestyGames
    Home»HOT»Apple Products»mac»5 Uses of Mac Applescript to Improve Productivity
    mac

    5 Uses of Mac Applescript to Improve Productivity

    5 Mins Read
    Facebook Twitter Pinterest LinkedIn Tumblr Email
    Share
    Facebook Twitter LinkedIn Pinterest Email

    Applescript is Apple’s little black programming language, but it’s a powerful tool that novice programs can enjoy. With a few clever Applescripts that handle the boring tasks, we can boost productivity and automate your blues.

    What is Applescript?

    Applescript interfaces with most Mac applications like Finder, iTunes, QuickTime, and Mail. If you’re familiar with Automator, Applescript is sort of a favored reformer translation of this app.

    1. Turn hidden files

    Save it as an app and you’ll have a clickable switch to reveal hidden files in Finder.

    set newHiddenState to “AND IT IS”
    try
    set oldHiddenState to do shell script “defaults read com.apple.finder AppleShowAllFiles”
    if oldHiddenState is in then
    set newHiddenState to “NO”
    end if
    end try
    do shell script “defaults write com.apple.finder AppleShowAllFiles “ & newHiddenState
    do shell script “killAll Finder”

    2. Rename Batch Files

    This script will prompt the target for a filename, then automatically rename the selected files with this text statement plus an incremental index. It even usefully adds leading zeros for files one through ten.

    — This code comes from https://gist.github.com/oliveratgithub/
    — Open in AppleScript Editor and save as Application
    — ———————————————— ————
    –this is required to break the filename into pieces (separate name and extension)
    set text item delimiters to “.”
    tell application “finder”
    set all_files to every item of (choose file with prompt “Choose the Files you’d like to rename:” with multiple selections allowed) ace list
    displaydialog “New filename:” default answer “”
    set new_name to text returned of result
    –now we start looping through all selected files. ‘index’ is our counter that we initially set to 1 and then count up with every file.
    –the ‘index’ number is of course required for the sequential renaming of our files!
    repeat with index desde 1 to the count of all_files
    –using our index, we select the appropriate file from our list
    set this_file to item index of all_files
    set file_name_count to text items of (get yam of this_file)
    –if the index number is lower than 10, we will add a preceding “0” for a proper filename sorting later
    if index is less than 10 then
    set index_prefix to “0”
    else
    set index_prefix to “”
    end if
    —
    –lets check if the current file from our list (based on index-number) has even any file-extension
    if number of file_name_count is 1 then
    –file_name-count = 1 means, we extracted only 1 text-string from the full file name. So there is no file-extension present.
    set file_extension to “”
    else
    –yup, we are currently processing a file that has a file-extension
    –we have to re-add the different file-extension after changing the name of the file!
    set file_extension to “.” & item –1 of file_name_count
    end if
    –let’s rename our file, add the sequential number from ‘index’ and add the file-extension to it
    set the yam of this_file to new_name & index_prefix & index & file_extension ace string
    end repeat
    –congratulations for successfully accomplishing the batch renaming task 🙂
    display alert “All done! Renamed” & index & “files with ‘” & new_name & “‘for you. Have a great day! :)”
    end tell

    3. Scale an image by percentage

    This script will resize images to 50% of their different size.

    The 5 best mice for Mac
    READ

    –Prompt for an image
    set theImageFile to choose file of type “public.image” with prompt “Please select an image:”

    — Locate an output folder
    set theOutputFolder to (way to desktop folder ace string)

    –Launch Image Events
    tell application “Image Events”
    launch

    –Open the image
    set theImage to open theImageFile
    tell theImage

    — Determine a save name for the image
    set theName to yam
    set theSaveName to “smlr-“ & theName

    — Scale the image by 50%
    scale by divider 0.5

    — Save the image to the output folder, using the save name
    save ace file type in (theOutputFolder & theSaveName)

    –Close the image
    close
    end tell
    end tell

    4. Adjust the image to the charm of the pixels

    This uses much of the hatching from the above scripts, but in your constituency it scales to the pixel charm. It will ask the favored for the desired pixel charm and add that pixel charm to the new filename hatch.

    Related : How to fix apps not showing up in Launchpad on macOS

    –Prompt for an image
    set theImageFile to choose file of type “public.image” with prompt “Please select an image:”

    set dialogResult to (displaydialog “Enter desired pixel width:” default answer “”) try set pixelWidth to (text returned of dialogResult) ace integer end try

    — Locate an output folder
    set theOutputFolder to (way to desktop folder ace string)

    –Launch Image Events
    tell application “Image Events”
    launch

    –Open the image
    set theImage to open theImageFile
    tell theImage

    — Determine a save name for the image
    set theName to yam
    set theSaveName to (pixelWidth ace text) & “-px-“ & theName

    6 of the fastest ways to create a short link on Chrome, Mac, iOS and Android
    READ

    — Scale the image to pixelWidth
    scale to size pixelWidth

    — Save the image to the output folder, using the save name
    save ace file type in (theOutputFolder & theSaveName)

    –Close the image
    close
    end tell
    end tell

    5. Save the folders to the chosen destination.

    This simple script duplicates a chosen folder to a chosen destination, which can make complicated drag-and-drop copying a little less painful.

    set backupTarget to (choose folder with prompt “Select a Backup Target”)
    set backupDestination to (choose folder with prompt “Select a Backup Destination”)
    tell application “finder”
    duplicate folder backupTarget to folder backupDestination
    end tell

    Conclution

    For more information on AppleScript, Apple’s own documentation can be found. Better yet MacOSXAutomation.com, which is more accommodating for newbies to use.

    • How to use Touch ID to authenticate sudo commands on a Mac
    • Polymail: The Ultimate Email Client for Mac and iOS
    • How to install Linux software on a Mac with MacPorts
    • Capto – Best Image & Video Screen Capture App for Mac
    • Doo – A Fun and Delicious Task and Reminder App for Mac and…
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email

    Related Posts

    Top 10 apps to prevent food waste

    Advantages of Snaptube when Downloading Facebook Videos

    8 Best Apps to Remove Background from Images

    Top Reviews

    Dentures and Demons 2 is a graphic horror adventure

    How to use ShadowExplorer to restore files from System Restore

    Padua, Siena, Rome, Bologna, Turin, the tour of the iOS 7.1 Base Course of Objective C continues

    BestyGames
    Facebook Twitter
    • About Us
    • Contact Us
    • Curation Policy
    • DMCA
    • Privacy Policy
    • Terms & Conditions
    © 2022 BESTYGAMES. Designed by SAMARANK .

    Type above and press Enter to search. Press Esc to cancel.