Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.bat Files Referencing Drive Locations #2

Open
indifferentghost opened this issue Dec 2, 2017 · 9 comments
Open

.bat Files Referencing Drive Locations #2

indifferentghost opened this issue Dec 2, 2017 · 9 comments

Comments

@indifferentghost
Copy link
Contributor

To use properly each drive location file would have to be set to the correct location. I propose either an initial setup after downloading this... Or a list of files that include drive locations.

@Sondro
Copy link
Owner

Sondro commented Dec 2, 2017

There should be some generic standards like myFilePath and myURL so you can do a multifile find/replace and setup/cfg all your .bats in one go... probably using another .bat ;)

I know VS Studio supports this, not sure about other IDEs yet.

@Sondro
Copy link
Owner

Sondro commented Dec 2, 2017

Wasn't sure if Robo3t or Postman should be registered in the Path var. My path var is getting pretty big when you consider all the other language stuff.

@indifferentghost
Copy link
Contributor Author

indifferentghost commented Dec 2, 2017

I suppose an alternative would be a bat file of registered variables and document notation to update these.
set e=c:/mypath/pathing/moar_pathing

@Sondro
Copy link
Owner

Sondro commented Dec 2, 2017

Well with windows you can temporarily register the path before the cmd instead of permanently adding it. If you're relying on .bats that might be preferable.

That main purpose of Cmds right now is:
1 - Fast demo/use for non-programmers/people who don't have time to use or look-up cmds
2 - Speed development for developers.

@indifferentghost
Copy link
Contributor Author

I will keep that in mind.

@Sondro
Copy link
Owner

Sondro commented Dec 3, 2017

Like I said, I have to/prefer to manually manage my path in the registry because there's a char limit to your path registered elsewhere.

A multi-file find/replace to direct paths using a widespread text editor like Wordpad with a .bat might be preferable. Haven't really gotten to testing that yet.

Also a lot of .bats with fancy path cmds don't work on various systems (and may make it harder to convert to bash later for non-win based solutions).

@indifferentghost
Copy link
Contributor Author

indifferentghost commented Dec 3, 2017

@echo off
setlocal

:Variables
set "_strFind=MyFile"
set /p "_strInsert=Set New file path:"

:Replace
for /f "delims=" %%a in ('forfiles /m *.txt /c "cmd /c echo @file"') do (
  echo %%a
  >new-%%a (
    for /f "usebackq delims=" %%i in (%%a) do (
      if "%%i" equ "%_strFind%" (echo %_strInsert%) else (echo %%i)
    )
  )
)

@pause

endlocal
@echo on

This is a very primitive find and replace system currently set to only search .txt and replace MyFile... It also outputs new-%filename%... But with minor alterations could suit a basic need.

@Sondro
Copy link
Owner

Sondro commented Dec 4, 2017

This is a good start.

Previously I had run into some limitations with .bat scripts and started using Advance Renamer

Will look into this when I have more time.

@Sondro
Copy link
Owner

Sondro commented Jan 7, 2018

Not fully setup yet, but we now have two options using JREPL.bat which uses regex to rapidly edit multiple files, and also a powershell parsing.bat if you want to do things slower/simpler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@Sondro @indifferentghost and others