View Single Post
  #1036  
Old 16.12.2019, 20:27
anonymous anonymous is offline
Baby Loader
 
Join Date: Sep 2019
Posts: 8
Default

Quote:
Originally Posted by mgpai View Post
Code:
// Rename files by matching download url pattern
// Trigger: Packagizer Hook

if (state == "BEFORE") {
    var patt = /.+\/domain\.com\/(foo)\/(bar)(\.zip)/i;
    var name = link.getURL().match(patt);
    if (name) link.setName(name[2] + "_" + name[1] + name[3]);
}

Packagizer rules not suitable for this?

Is this what I would need to use in the case of creating a directory and subdirectory based on the pinterest url?

example links are
**External links are only visible to Support Staff****External links are only visible to Support Staff**
**External links are only visible to Support Staff****External links are only visible to Support Staff**

mine was more like this with my basic javascript knowledge so, i didn't know exactly how to apply it to this situation
Code:
testVar = document.URL
testVar = **External links are only visible to Support Staff**

const [first, second] = testVar.split("/").filter(n=>n).slice(-2);
	if pinterestURL
		if the url is in this format, 
			main folder is first string 
			subfolder is second string
        ...

first = stewipanzon
second = english-bull-terrier
Hoping someone can understand my intent
Reply With Quote