I was just going over some projects I need to transfer to others team members and was reminded of all the utility apps I created. Particularly on that covers Windows paths to Linux....

Or basically path.Replace("\\","/") in a GUI.

I actually use it a lot whenever I hardcode a file path in Java for testing or make some partial path Linux compliant.

I think it saves me a lot of time but I'm the only person I think that creates these apps... basically for anything I find myself repeating often... Even these simple things.

Am I weird? Or just good at identifying things that can be outsourced? And outsourcing them?

  • 2
    I have some apps like that.
    I need to build more.
  • 0
    Ok. this is a solved problem. Use the framework provided filepath, or os.path matching package instead of this "inventing the wheel, but this time, as a triangle" shit.
  • 0
    @magicMirror string path = "c:\some\long\path\file.txt"

    Java will say that string is bad no matter what. There is no shortcut to tell it not to escape the \ unlike Python or C#

    If you put that in a Linux shell script, will also fail
  • 0
    @billgates yup. triangles all the way....
  • 2
    @magicMirror so what's your solution? And using Linux as a dev env is not valid...
  • 3
    Windows accepts / anyway why use \ at all ?
  • 0
    @muttley Linux and programming languages don't because \ is the escape character for like \t, \n. Needs to escape it with \\ or use /
  • 0
    @billgates in C# I use a combination of:

    Not all at once, but it depends on what I have in the function and how much I want to refactor.
  • 0
    @billgates solution is easy.
    1. why do you need to convert?
    2. what code are you using to convert?

    1 - the answer is usualy, no actual direct need. Can pass as arg on command line, or file with paths.
    2. use the framework path standard methods to handle path loading, manipulation and usage.
  • 0
    @bkwilliams yes @ and r"" are compiler supported helpers which just tells it treat everything in the following "" literally. They make things easier but not all languages have them and I don't think Linux shell script does either.

    At run/compile time they are converted to \\.

    So I copy a file path from Explorer, I need all the \ escaped or changed to an /
  • 1
    @billgates i said the opposite always use / it works in windows and *nix
  • 0
    @magicMirror I am running a simple program that just needs some input/output path. Yes I could prompt Every time it change the run configs but it's more efficient to just hard code it into the program so I don't have to input it every time.
  • 0
    @muttley because Windows Explorer converts and outputs all paths with \. Also I think cmd doesn't like / for some things...
  • 1
    @billgates Yup. I understand the logic.

    Reminds me of when I just started to play around with perl circa 1999. coded a horrendus zero padding monster, using if statements only. Worked, but damn it was hard to look at later.....
  • 1
    if you are able to code them, and they are usable by others, that's great.
    Most of tools I do are done in such a hurry that I'm the only one to understand them....
  • 0
    @deviloper well same with mine, only user is me...

Your Job Suck?
Get a Better Job
Add Comment