Note that there are some explanatory texts on larger screens.

plurals
  1. POuntangling directory separator madness using string manipulation?
    primarykey
    data
    text
    <p>I'm working on converting a website. It involved standardizing the directory structure of images and media files. I'm parsing path information from various tags, standardizing them, checking to see if the media exists in the new standardized location, and putting it there if it doesn't. I'm using string manipulation to do so.</p> <p>This is a little open-ended, but is there a class, tool, or concept out there I can use to save myself some headaches? For instance, I'm running into problems where, say, a page in a sudirectory (<code>website.com/subdir/dir/page.php</code>) has relative image paths (<code>../images/image.png</code>), or other kinds of things like this. It's not like there's one overarching problem, but just a lot of little things that add up. </p> <p>When I think I've got my script covering most cases, then I get errors like <code>Could not find file at export/standardized_folder/proper_image_folderimage.png</code> where it should be <code>export/standardized_folder/proper_image_folder/image.png</code>. It's kind of driving me mad, doing string parsing and checks to make sure that directory separators are in the proper places. </p> <p>I feel like I'm putting too much work into making a one-off import script very robust. Perhaps someone's already untangled this mess in a re-useable way, one which I can take advantage of?</p> <p><strong>Post Script:</strong> So here's a more in-depth scoop. I write my script that parses one "type" of page and pulls content from the same of its kind. Then I turn my script to parse another type of page, get all knids of errors, and learn that all my assumptions about how paths are referenced must be thrown out the window. Wash, rinse, repeat. </p> <p>So I'm looking at doing some major re-factoring of my script, throwing out all assumptions, and checking, re-checking, and double-checking path information. Since I'm really trying to build a robust path building script, hopefully I can avoid re-inventing the wheel. Is there a wheel out there?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload