Skip to content

Instantly share code, notes, and snippets.

@MarshySwamp
Created March 11, 2022 11:18
Show Gist options
  • Save MarshySwamp/82f910aa69a7534838b30d30ab3ef5ad to your computer and use it in GitHub Desktop.
Save MarshySwamp/82f910aa69a7534838b30d30ab3ef5ad to your computer and use it in GitHub Desktop.
Remove %20 from folder name text string
/* Remove %20 character from folder name via RegEx */
var inputFolder = Folder.selectDialog("Select the input folder:");
alert("Original Folder Path:" + "\r" + inputFolder);
// Full path fsName + RegEx
var inputFSname = inputFolder.fsName.replace(/(?:.+\/)(.+)$/, '$1');;
alert("FS Name:" + "\r" + inputFSname.toSource());
// Remove %20 space code via regex
var inputRegEx = inputFolder.name.replace(/%20/g, ' ');
alert("RegEx:" + "\r" + inputRegEx.toSource());
/* Remove %20 character from folder name without RegEx */
// Remove %20 space via decodeURI
var inputDecodeURI = decodeURI(inputFolder.name);
alert("Decode URI:" + "\r" + inputDecodeURI.toSource());
// Remove %20 space via displayName
var inputDisplayName = inputFolder.displayName;
alert("Display Name:" + "\r" + inputDisplayName.toSource());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment