You are not logged in.

#1 05 Jul 2014 21:35

hozza
Member
Registered: 05 Jul 2014
Posts: 27

is it possible?

I want to know what is the command if i want to remove dir when not knowing which drive it located for example:

RD /s /q "C:\Games\Test_game\mods"
MD C:\Games\Test_game\mods\new mods

proplem here is that i wanna compile this batch file to exe and this folder don't always be in drive C
so is there way that there is command that finds that location of "mods" and do the rest of command automaticly

sorry for bad english

Offline

#2 06 Jul 2014 03:40

Honguito98
Member
From: Mexico
Registered: 19 Sep 2013
Posts: 57

Re: is it possible?

Path to Mods is randomly? or the drive letter changes it?

This searchs any specified folder on any drive:

@Echo off
Set "ModsP=Games\Test_game\mods"
For %%d in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do (
 if exist "%%d:\%modsP%" (
  RD /s /q "%%d:\%modsP%"
  Echo.Mods folder founded @ "%%d:\%modsP%"
 )
)

Code not tested

Last edited by Honguito98 (06 Jul 2014 03:48)


.::{Honguito98}::.

Offline

#3 06 Jul 2014 09:30

hozza
Member
Registered: 05 Jul 2014
Posts: 27

Re: is it possible?

That will work fine thank you so much!
next hard question what if you dont know drive letter and one of path folder example:
?:\??????\Test_games\mods
if you have solution for this too code will be perfect!

Offline

#4 06 Jul 2014 20:29

Honguito98
Member
From: Mexico
Registered: 19 Sep 2013
Posts: 57

Re: is it possible?

Try this:

@Echo off
SetLocal DisableDelayedExpansion
If "%1" Equ "/?" Goto :Syntax
If "%1" Equ "-h" Goto :Syntax
If "%1" Equ ""  Goto :Syntax
If "%2" Equ ""  Goto :Syntax

Set "Game=%1"
Set "Mods=%2"
Set "Cd_=%Cd%"
Set "Item=0"
For %%d in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do (
	If exist %%d: (
		Cd /d %%d:
		For /F "Delims=" %%f in ('Dir /A:D /s /b "%Game%" 2^>Nul') Do (
			For /F "Delims=" %%m in ('Dir /A:D /s /b "%Mods%" 2^>Nul') Do (
				Set Item=1
				RD /s /q "%%~m"
				Echo.'%Mods%' folder founded @ '%%~m'
				If /i "%3" Equ "/F" Call :Ask "%%~m"
			)
		)
	)
)
Cd /d "%Cd_%"
If %Item% Equ 0 (
	Echo; '%Mods' Folder not founded!
) Else (
	Echo;Finished!
)
EndLocal
Goto :Eof

:Syntax
	Echo; ===Mods Founder ^& Deleter===
	Echo; Find a folder on any drive or/and any tree folder
	Echo;
	Echo; Syntax:
	Echo;     Modsf.bat ^<NameOfGame^> ^<NameOfFolderMods^> [/f]
	Echo;
	Echo; Commands:
	Echo;      '/f'      Ask to user to create a new folder.
	Echo;
	Echo; Examples:
	Echo;     Modsf.bat  Test_Game Mods
	Echo;     Modsf.bat  Doom GameConf /f
	Echo;
Goto :Eof

:Ask	
	Choice /M "Create a new folder"
	If %Errorlevel% Equ 1 Call :New "%~1"
	Goto :Eof

:New
SetLocal EnableDelayedExpansion
	Set "Tmp_=%~1"
	Set "Tmp_=!Tmp_:\%Mods%=!"
	SetLocal DisableDelayedExpansion
	:New_
	Set/p "Fl=Type the name of new folder, then press enter:"
	If Exist "%Tmp_%\%Fl%" (
		Echo;Folder name already exist!
		For /L %%a in (1,1,50000) Do Rem
		Goto :New_
	)
	Md "%Tmp_%\%Fl%"
	Goto :Eof

Result:

C:\Users\honguito\Desktop\Bat\Game_Batch_Files\s>ModsF.bat
 ===Mods Founder & Deleter===
 Find a folder on any drive or/and any tree folder

 Syntax:
     Modsf.bat <NameOfGame> <NameOfFolderMods> [/f]

 Commands:
      '/f'      Ask to user to create a new folder.

 Examples:
     Modsf.bat  Test_Game Mods
     Modsf.bat  Doom GameConf /f


C:\Users\honguito\Desktop\Bat\Game_Batch_Files\s>ModsF.bat test_game mods
'mods' folder founded @ 'F:\allaal\test_game\mods'
'mods' folder founded @ 'F:\allaal - copia\test_game\mods'
Finished!

C:\Users\honguito\Desktop\Bat\Game_Batch_Files\s>Md "test_game\mods"

C:\Users\honguito\Desktop\Bat\Game_Batch_Files\s>Md "F:\allaal - copia\test_game\mods"

C:\Users\honguito\Desktop\Bat\Game_Batch_Files\s>ModsF.bat test_game mods
'mods' folder founded @ 'C:\Users\honguito\Desktop\Bat\Game_Batch_Files\s\test_g
ame\mods'
'mods' folder founded @ 'F:\allaal - copia\test_game\mods'
Finished!

C:\Users\honguito\Desktop\Bat\Game_Batch_Files\s>

Last edited by Honguito98 (06 Jul 2014 20:41)


.::{Honguito98}::.

Offline

#5 07 Jul 2014 09:15

hozza
Member
Registered: 05 Jul 2014
Posts: 27

Re: is it possible?

Didn't get this last one working so i give you full description what i'm doing so here it is:
I have a game that is updated frequently and every update mod's in mods folder becomes useless and have to rework them suitaple for new update
so I want batch file what cleans that res_mod folder and make new folder(0.9.1) inside res_mods  and also wanna share that with my friends!
proplem here is that all these friends haven't installed this game in default path for exsample one of them has istalled it D:\Nettipelit\Game_name\res_mods\0.9.0
only invariable in this path is Game_name\res_mods
default mod path is C:\Games\Game_name\res_mods\0.9.0 where 0.9.0 changes every update (0.9.1, 0.9.2, 0.9.3 and so on)
and some of mod files is root of res_mods and main mod files are in 0.9.0

Thank you for your help so far!

Offline

#6 07 Jul 2014 16:55

Honguito98
Member
From: Mexico
Registered: 19 Sep 2013
Posts: 57

Re: is it possible?

It seems minecraft
What mods are in res_mod root?


.::{Honguito98}::.

Offline

#7 07 Jul 2014 17:40

hozza
Member
Registered: 05 Jul 2014
Posts: 27

Re: is it possible?

xvm (folder), Mmap.xml and viewrange.xml

Offline

#8 07 Jul 2014 19:40

hozza
Member
Registered: 05 Jul 2014
Posts: 27

Re: is it possible?

and no its not minecraft

Offline

Board footer

Powered by