AppleScript – How to replace text

How to replace part of string with AppleScript set theText to "On Tuesday, I told you to have the report ready by next Tuesday." set theText to findAndReplaceInText(theText, "Tuesday", "Friday") display dialog theText   on findAndReplaceInText(theText, theSearchString, theReplacementString) set AppleScript's text item delimiters to theSearchString set theTextItems to every text item of theText set AppleScript's … Continue reading AppleScript – How to replace text

ExtendScript – How to delete a folder

How to remove a folder with ExtendScript. This code will delete a folder and all it's contents. Be very careful as you won't be able to undo. var folderPath = "/Users/YourUserName/Desktop/fakeFolderName" var terminalCommand = 'rm -R -f "' + folderPath + '"' //for Photoshop //app.system(terminalCommand) //for After Effects system.callSystem(terminalCommand) //This function below takes in a file path and deletes that folder. //pass in path. This destroys the folder/ file that you pass in... Gone forever... Be careful. function deleteThisFolder(folderPath){     //sometimes we get '~/Desktop/Folder/NextFolder'. The '~' path won't work for terminal. This changes it back to "Users/userName/Desktop" format. This line of code below will solve that if your path is funky.     //var folderPath = Folder(folderPath).fsName;     var terminalCommand = 'rm -R -f "' + folderPath + '"'     //Photoshop     app.system(terminalCommand)     //After Effects … Continue reading ExtendScript – How to delete a folder

ExtendScript – Remove last item path

How to remove the last item from string with extendscript. This function takes in a path string and returns a string without the last item in the Path. Try it out in your adobe scripts. //Remove last item from a string   var passThisPath="/Users/YourUserName/Desktop/fakeFolder"; var smallerPath = returnPathWithoutLastItem(passThisPath) alert(smallerPath) function returnPathWithoutLastItem(myPath){             if(myPath!==false && myPath.toString().length>1 && myPath.toString().split("/").length>1){     … Continue reading ExtendScript – Remove last item path

ExtendScript – How To Zip A Folder

  How to zip a folder in ExtendScript This script goes through terminal (command line) to zip a folder with ExtendScript. var locationOfNewZip = "/Users/YourUserName/Desktop"; //path to the folder where you want your .zip file to appear var nameOfFolderToBeZipped = "myFakeFolder";  // this is the name of the folder that get's zipped up var nameOfNewZippedFolder = nameOfFolderToBeZipped + ".zip"; //Just the name of your new zip, not a path var terminalCommand = 'cd "' + locationOfNewZip + '" && zip -r -X "' + nameOfNewZippedFolder + '" "' + nameOfFolderToBeZipped + '"'; //for After Effects. Returns terminal result var test = app.system(terminalCommand) //photoshop //app.system(terminalCommand)   //This is a more complex version that takes in a path string and pushes out a zip for you: var myNewZip = zipFolder("~/Desktop/MyFolderName"); //places … Continue reading ExtendScript – How To Zip A Folder