Sondro / Cmds

Useful Commands for Programming
MIT License
0 stars 1 forks source link

.bat Files Referencing Drive Locations #2

Open indifferentghost opened 6 years ago

indifferentghost commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

I will keep that in mind.

Sondro commented 6 years ago

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 commented 6 years ago
@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 commented 6 years ago

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 commented 6 years ago

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.