Reputation: 13548
I am generating images of webpages from urls and writing them to my local filesystem, and I want to name the image by its url. However, if I do this, since there are /
's in the url, it will create new directories instead of calling the image by the entire url. Is there a way to avoid this?
Upvotes: 1
Views: 64
Reputation: 24717
I don't believe it's possible to place a / or \ in a file name. The best thing I can think to recommend is replacing all / or \ with alternate characters not normally found in URLs, such as $ ^ , !. If you can't find a single character to replace the slash, you can use a short string that's unlikely to be in the URL, such as [slash] or a combination of symbols.
The problem to watch out for when using the short string is the length of the file names. Although most OSes won't have a problem, you may not be able to zip them with their full name.
Upvotes: 1