codemuffin

Humble Bundle Renamer - jQuery - v1.1 - Fixed CDN URL Path

May 25th, 2025
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | Source Code | 0 0
  1. /*/
  2. * CHANGELOG
  3. * 2018-xx-xx - 1.0.0 - Initial
  4. * 2025-05-25 - 1.1.0 - Fixed CDN URL Path
  5. */
  6.  
  7.  
  8. // Create an array to store our batch file lines
  9. var output = [];
  10.  
  11. // Build the array
  12. $('.js-all-downloads-holder .whitebox-redux .row').each(function(){
  13. // Get name
  14. var name = $(this).find('.gameinfo .title a:first-child').text().trim();
  15.  
  16. // Replace illegal characters (you can change the "" in the second parameter to whatever you like, as with the first line)
  17. name = name.replace(":", " -");
  18. name = name.replace("?", "");
  19. name = name.replace("*", "");
  20. name = name.replace("|", "");
  21.  
  22. // Get filenames & add them to the output array
  23. $(this).find('.downloads .download .a').each(function() {
  24. // Get single link URL
  25. var url = $(this).attr('href');
  26.  
  27. // Remove the query string from the URL
  28. var urlQueryIndex = url.indexOf('?');
  29. var urlSliced = url.slice(0, urlQueryIndex);
  30.  
  31. // Remove the domain path
  32. // OLD 2018: https://dl.humble.com/
  33. // NEW 2025: https://cdn.humble.com/humblebundle/
  34. var filename = urlSliced.replace("https://dl.humble.com/", "");
  35.  
  36. // Get the file extension (".pdf", etc)
  37. var extensionIndex = urlSliced.lastIndexOf('.');
  38. var extension = url.slice(extensionIndex, urlSliced.length);
  39.  
  40. // Batch file renaming convention is "rename [old filename] [new filename]"
  41. var oldFilename = filename;
  42. var newFilename = name + extension;
  43. var batLine = 'rename ' + oldFilename + ' "' + newFilename + '"';
  44. output.push(batLine);
  45. });
  46. });
  47.  
  48. // Create an empty textarea, and usage instructions
  49. $('.js-all-downloads-holder .whitebox-redux').prepend('<div style="margin-bottom: 20px;font-size: 18px;line-height: 25px;"><strong>Batch Renamer Instructions:</strong><ol><li>Copy and paste the text below into an empty text file named "renamer.txt"</li><li>Rename this file to "renamer.bat" (without quotes)</li><li>Put the file into a folder with all of your downloaded files (be sure to make backups first, just in case!)</li><li>Double-click the .bat file, and your files will be renamed!</li></ol></div><textarea class="batch-file-output" style="width: 100%; min-height: 500px;margin-bottom: 20px;"></textarea>');
  50.  
  51. // Output the array to the textarea
  52. $.each(output, function(index, value) {
  53. console.warn(value);
  54. $('.batch-file-output').append(value + "\n");
  55. });
Add Comment
Please, Sign In to add comment