1.

Solve : First time batcher needing help.?

Answer»

First let me appologise if this has been covered somewhere. i did look, but its hard to find something when you dont know the words you need

ok when you install games and programs in windows, it asks you to choose an installation location.

Is there a way to put into a batch file code that will seek the location of the folders you wish to modify.

in most instances the FOLDER i seek would normally reside in either C:\Games\folder or C:\Program Files\Folder.

based on my need, this would be run on several OS's(mainly XP/Vista/7), but hopefully apart from any syntax issues, it should be a simple batch that is able to run on all.

If it is not possible to program the batch to seek the location, is it possible to enable the user to manually enter it through the cmd box?

I really hope you guys can help You seem to be wanting the use of the dir command if you are just looking for locations.

dir /s /b "*somegame*"

That will search for all instances of "somegame" in the directory the batch is run under (which means if you "cd.." until you get to just the drive, you will search the entire drive.) Most times, where you run your batch will not be more than 10 folders deep in the file structure, however you can add more onto the below if you think you need to. Put this before the dir to search the entire structure:

cd..\..\..\..\..\..\..\..\..\..\

If you are just wanting to search in the specified folders (Games and Program Files) then change the cd command to cd c:\games or cd "c:\Program Files"

Of course all of this just outputs the full file path of the location of those files. When you say Quote

Is there a way to put into a batch file code that will seek the location of the folders you wish to modify.
I honestly don't know how to help unless you give me a little more information. Are you wanting explorer to open up to the file location? Are you wanting a batch to perform some tasks on the files within the folder? What modification are you looking to perform?

BTW, these commands will work equally well on all listed OS's.Sorry i should have explained what the entire job of the batch file is.
this is just an expresion of intent as i dont know batch language very well at all.

1. find install location.
2. create back up folder
3. move files from installed/subdir to install/subdir/backup
4. copy new files from /modinstall folders to installed/subdir
5. run /installed/file.exe
6. wait for file.exe to terminate
7. delete files(that we copied) from installed/subdir
8. restore files from /installed/subdir/backup to /installed/subdir

It will be fairly simple i think to do most of that, but in order for the whole thing to work, the batch file needs to be able to locate /installed or the entire script is for nothing.would just like to point out, im only asking for help with step 1, the rest i want to try myself, but i wouldnt know where to begin on step 1Okay, this gets a little tricky, because the location could be quite variable as far as where in the subdir the actual files you are trying to modify are located. If you are willing to do a little preliminary work, I can help you with a simple batch that will get the location. Let me know if you would like to do that, or if you are wanting ONE that will find what you are looking for WITHOUT prelim work.im willing to do whatever it takes to get this thing working.

the main thing is that the user recieving my files doesnt have to do anything except run the bat (and maybe type in their install location if it cant be auto DETECTED)

basicly the point of this bat is to make something that is complicated quite simple for them. can we use the file.exe as the anchor? its in the top directory of everything that needs to be modified.If you are looking for the "file.exe", then it becomes easy, so long as it is a unique name.

Code: [Select]echo off
cd ..\..\..\..\..\..\..\..\..\..\
for /f %%A in ('dir /s /b "file.exe" ') do set location=%%~dpA

Now if you are not certain if the "file.exe" will be unique (for example install.exe), then you just have to add a little more to ensure you grab the right one.

Code: [Select]echo off
cd ..\..\..\..\..\..\..\..\..\..\
for /f "delims=" %%A in ('dir /s /b "file.exe" ') do (
  echo %%A | find "[Unique folder string]"
  if errorlevel 0 set location=%%~dpA
)

Obviously you would need to substitute the [Unique folder string] with something that is unique to the name of the folder you are trying to get.

After either of these, the location variable should hold the folder you are trying to grab. If you need any help with any of the additional steps, please let us know. Quote from: Raven19528 on November 14, 2011, 09:47:04 AM
Most times, where you run your batch will not be more than 10 folders deep in the file structure, however you can add more onto the below if you think you need to. Put this before the dir to search the entire structure:
cd..\..\..\..\..\..\..\..\..\..\


Or just use \ to specify the root directory. Quote from: BC_Programmer on November 15, 2011, 11:01:30 AM
Or just use \ to specify the root directory.

Or that... Thank you very much!

LoL, i dont understand it, but it does look like the kind of thing that will work.

its going to be a very steep learning curve for me, and may take weeks till i get my head round it.

i will pop back in and report my progress and ask for more help if desperate...once i finish...or fail to finish, as the case may be. i will post the entire code here and the specific use it has come to.

It is very tempting to keep asking, i have more questions than answers atm, but as they say, "give a man a fish and he will eat for a day, teach him how to fish and he will eat for the rest of his life" Quote from: GiGaBaNE on November 15, 2011, 11:41:27 AM
"give a man a fish and he will eat for a day, teach him how to fish and he will eat for the rest of his life"

Yeah, but that's pretty close to, "The best way to teach a man to swim is to throw him in the water. The success rate is 100% for those who survive."  Quote from: Raven19528 on November 15, 2011, 11:48:37 AM
Yeah, but that's pretty close to, "The best way to teach a man to swim is to throw him in the water. The success rate is 100% for those who survive." 

The thing is, many people who visit forums like this regularly prefer helping someone who has made some kind of effort, to writing a whole script for somebody who isn't really interested in how it works.


Discussion

No Comment Found