Skip to main content
Inspiring
November 3, 2021
Answered

Issue with spaces in a name when using file.parent.name. How do I deal with %20 ?

  • November 3, 2021
  • 1 reply
  • 379 views
I have a script to streamline some importing tasks. Part of this script (below) takes the name of the Finder folder containing the footage and creates a AE folder and Comp using that name.
 

 

// Get Finder folder name of footage items
var myFinderFolder = myItems[0].file.parent.name;
            
// Create main folder with name of Finder folder
var myCompFolder = app.project.items.addFolder(myFinderFolder);

// Place main folder in location of selected footage
myCompFolder.parentFolder = myItems[0].parentFolder;

// Create comp with name of the Finder folder
var myComp = app.project.items.addComp(myFinderFolder,1920,1080,1,60,24);

// Move comp to myCompFolder
myComp.parentFolder = myCompFolder;

 

 

It works great until I encounter a Finder folder with spaces in the name. In the AE folder it will look like this… "My%20Animated%20Character"

 

How can I add a line that looks for %20 and replaces it with a real space? Or is there a better way to deal with this? Also, are there other illegal characters I need to be aware of?

This topic has been closed for replies.
Correct answer Paul Tuersley

var myFinderFolder = File.decode(myItems[0].file.parent.name);

https://extendscript.docsforadobe.dev/file-system-access/file-object.html#decode

 

1 reply

Paul TuersleyCorrect answer
Inspiring
November 3, 2021

var myFinderFolder = File.decode(myItems[0].file.parent.name);

https://extendscript.docsforadobe.dev/file-system-access/file-object.html#decode

 

Inspiring
November 3, 2021

Exactly what I was searching for. Thanks again Paul.