Enigma 78 Posted December 28, 2014 Report Share Posted December 28, 2014 Sometimes you scrape the web and want to create a folder on your computer with for instance the title of a post that you scraped from the web, but that title might contains characters (so called "illegal characters") that you are not allowed to use in Windows for saving files.If so it will result in an error "Illegal characters in path" (or something similar). To prevent this you should remove these characters before saving or creating files and folders. Following this article http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29 it shows that the following characters are considered "illegal" when it comes to file names: < (less than)> (greater than): (colon)" (double quote)/ (forward slash)\ (backslash)| (vertical bar or pipe)? (question mark)* (asterisk) So if you want to create a folder or save a file and use text that you scraped from the web, save yourself some issues and always Set the text in a variable and $replace regular expression that variable and then finally save it. Here is just an example code that has some text with illegal characters, the illegal characters get replace with nothing.I know the folder on your desktop still contains some weird characters, but these are not illegal, and thus allowed to use.This is just an example of course. Here is the code: set(#test, "te*st!@\"\\[\\^\\.*@-\\]\\\\/\\_-HAHA:49;6,^;*|/\\?><=", "Global") set(#test, $replace regular expression(#test, "[@,\"^:;*|\\/?><=\\\\/]", ""), "Global") create folder($special folder("Desktop"), #test) Eventually a default function for this in uBot would save this extra step (for instance Save to file, Create folder, etc.) should do this automatically.Or does anyone know a valid reason why not?Let me know. I hope this tutorial helps someone Have a good one 3 Quote Link to post Share on other sites
bitterbrowns 0 Posted March 21, 2015 Report Share Posted March 21, 2015 (edited) I have ubot standard edition can you explain to me exactly how i would set that up.I get the set to variable but what is "te*st!@\"\\[\\^\\.*@-\\]\\\\/\\_-HAHA:49;6,^;*|/\\?><=" is that some kind of wild card? Don't worry I figured it out but thanks for the example. Edited March 21, 2015 by bitterbrowns Quote Link to post Share on other sites
johnwalton 12 Posted October 10, 2016 Report Share Posted October 10, 2016 thanks! this worked like a charm. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.