Jump to content

Shorten Web File Name - path too long


Recommended Posts

@JockoDundee The browser still has access to the modified HTML by any scripts, it can save that instead. I don't know how a browser would handle a URL change (which is local), but I guess it just uses the base name of the new URL.

EasyCodeIt - A cross-platform AutoIt implementation

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to post
Share on other sites
4 hours ago, TheDcoder said:

The browser still has access to the modified HTML by any scripts, it can save that instead.

Yes, but not all scripts run on page load.  Some run only when a button is clicked, which means that saved archive will only have the code to generate the URI, not any modified HTML.  Later, if the archive is used, the JS will generates the local call but it would fail if the local filename had been shortened.

I could be wrong, but even if I’m not it’s hardly a show-stopper, IMHO @TheSaintis only trying to provide a reasonable facsimile of the site, not a mission critical replica, so I feel like I’m nitpicking to even mention it.

Code hard, but don’t hard code...

Link to post
Share on other sites
51 minutes ago, JockoDundee said:

Later, if the archive is used, the JS will generates the local call but it would fail if the local filename had been shortened.

Oh, right, I got what you are saying now... that should definitely not work on a saved local copy with modified names.

52 minutes ago, JockoDundee said:

IMHO @TheSaintis only trying to provide a reasonable facsimile of the site, not a mission critical replica, so I feel like I’m nitpicking to even mention it.

I bet you are right on the money 💰

Most people would be saving pages for their visual content anyway... but there would be some unlucky people like me who would have tried to save an interactive page, or a page with a game (RIP Adobe Flash :rip:). Obviously those types of pages are hard to preserve, especially with an automatic method like a browser.

EasyCodeIt - A cross-platform AutoIt implementation

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to post
Share on other sites
4 minutes ago, Somerset said:

Good riddance to outdated security ridden nightmare.

For sure, JavaScript is much better but I will miss all those quirky flash games :(

Such type of games will probably be never made again.

EasyCodeIt - A cross-platform AutoIt implementation

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to post
Share on other sites
10 hours ago, JockoDundee said:

One question: what happens with shortened URI’s that are dynamically created via JS?  
For instance, let’s say there is a hard link to a static img “GOG/too........long.jpg”, which is also called via JS using string concatenation?

Well I did say my code wasn't foolproof, and so anything real tricky, maybe something referenced in a CSS file for example, then my code wouldn't deal with it.

My code only deals with a file name, not even a path, though it scans all sub-folders for a same or similar named file, and if more than one instance of the file exists, the renaming does not occur and the user is notified of such. So my code is simplistic in that it only corrects the file name, not path, in the html files.

You could of course develop much more complex code to deal with other possibilities, but as I said in my first post, my code works well enough for the situation I am using it ... chiefly GOG game web pages, where the conditions are kind of stable and known.

I also mentioned that improvements to the code would be welcome. :)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to post
Share on other sites
  • 2 weeks later...

sorry for the late reply. two things i found useful in the past dealing with this kind of issue were:

the quick'n'dirty way: use the SUBST command to shorten the base path to a single drive letter. before placing anything in the target folder, do something like this:

SUBST X: "C:\Users\TheSaint\Downloads\2021\02\10\GoG\Irony Curtain - From Matryoshka with Love - Revolutionary Edition\_Html"

later in your code, refer to X: instead of that long path.

although this works, this method has some obvious caveats, and i never use it anymore now that i have a more professional method: use unicode functions to handle your copy/move/etc file operations. i made a UDF to streamline the process, so now i have absolutely no worries about long path issues. you can just use the UDF as is, or look inside to see how it's done and implement only the bits and pieces you find useful.

Link to post
Share on other sites

Thanks for the suggestions, and if I was just doing it for me, they or some of the others suggested would probably do the job. They won't help my kids etc.

Not sure using a substitute drive would help. It might as far as source files go, but the destination folder path needs to be similar to the original source one, as that is how I structurally store my stuff.

In any case, I'd rather cure than bandaid the situation. I'd use Dcoder's suggestion of the browser addon as a preventative measure, if it wasn't such a pain, so that everything was saved decently in the first place ... no cure or bandaid needed in that scenario.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...