new to batch scripts

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
mkenney84
Posts: 3
Joined: 16 Nov 2017 10:53

new to batch scripts

#1 Post by mkenney84 » 16 Nov 2017 11:05

Code: Select all

 INFO.BAT version 1.4
--------------------------------------------------------------------------------
Windows version        :  Microsoft Windows [Version 10.0.15063]
Product name           :  Windows 10 Home, 64 bit
Performance indicators :  Processor Cores: 4      Visible RAM: 16734924 kilobytes

Date/Time format       :  (mm/dd/yy)  Thu 11/16/2017  10:50:13.95
__APPDIR__             :  C:\Windows\system32\
ComSpec                :  C:\Windows\system32\cmd.exe
PathExt                :  .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
Extensions             :  system: Enabled   user: Enabled 
Delayed expansion      :  system: Disabled  user: Disabled
Locale name            :  en-US       Code Pages: OEM  437    ANSI 1252
DIR  format            :  11/16/2017  10:41 AM     3,086,979,072 pagefile.sys
Permissions            :  Elevated Admin=No, Admin group=Yes

                          Missing from the tool collection:  debug

Ok so what i have is this in C:\Users\User\Desktop\maps\accounts are 12 folders with different names of cities. Inside each folder is an accounts.csv file in format of login,name,password 1 per line. I also have currently a spare .txt file with backup of same format of current running .csv My goal here is to run a script which changes current accounts.csv in each folder to old.csv and compile all 12(1 from each folder ) together 1 per line in another folder or text doc or anywhere that would work. Then change the spare .txt file to the name of accounts.csv

TheHunterManX
Posts: 54
Joined: 14 Aug 2015 05:59

Re: new to batch scripts

#2 Post by TheHunterManX » 17 Nov 2017 12:49

I don't quite understand what your trying to do.
So, instead of questioning you and making you wait for a batch file, here's just the thing!

Code: Select all

@echo off
REM Set this value to true to check for an accounts.csv file existing, otherwise set to false.
set check1=true
REM Set this value to true to check if old.csv file exists, otherwise set to false.
set check2=true
REM Set this value to true to put new file to all dictionaries, otherwise set to false.
REM Either way, accounts.csv in batch folder will be made.
set dictionaryoutput=true
set temp1=
echo deleting old accounts.csv generated by bat file
if exist accounts.csv del accounts.csv
echo copying all text from accounts.csv files...
for /F "tokens=* delims=" %%A in ('dir /a:d /b') do (
if %check1%==true if exist "%%A\accounts.csv" call :accountcheck "%%A"
if %check1%==false call :accountcheck "%%A"
echo.>>accounts.csv
)
)
if %dictionaryoutput%==true echo putting text into all dictionaries...
if %dictionaryoutput%==true for /F "tokens=* delims=" %%A in ('dir /a:d /b') do (
type "accounts.csv">%%A\"accounts.csv"
)
echo Done!
pause
exit /b 0
:accountcheck
set temp1=%1
set temp1=%temp1:"=%
if exist accounts.csv type "%temp1%\accounts.csv">>"accounts.csv"
if not exist accounts.csv type "%temp1%\accounts.csv">"accounts.csv"
if %check2%==true if not exist "%temp1%\old.csv" ren "%temp1%\accounts.csv" "old.csv"
if %check2%==false ren "%temp1%\accounts.csv" "old.csv"
goto :EOF
I have already tested the batch file. If you run it after the first time, the amount of information will double.

mkenney84
Posts: 3
Joined: 16 Nov 2017 10:53

Re: new to batch scripts

#3 Post by mkenney84 » 17 Nov 2017 13:16

i made probably the noobiest script youve ever seen but this worked when i ran it....if anyone cares to give me some feedback id love it this is just what i was able to come up with thats super simple for a beginner like me

Code: Select all

@ECHO on
cd C:\Users\User\Desktop\maps\accounts\Downtown
ren accounts.csv shadbans.txt
move shadbans.txt C:\Users\User\Desktop\names
ren spare.txt accounts.csv
cd C:\Users\User\Desktop\maps\accounts\Dunes
ren accounts.csv shadbans1.txt
move shadbans1.txt C:\Users\User\Desktop\names
ren spare.txt accounts.csv
cd C:\Users\User\Desktop\maps\accounts\Greenville
ren accounts.csv shadbans2.txt
move shadbans2.txt C:\Users\User\Desktop\names
ren spare.txt accounts.csv
cd C:\Users\User\Desktop\maps\accounts\lemars
ren accounts.csv shadbans3.txt
move shadbans3.txt C:\Users\User\Desktop\names
ren spare.txt accounts.csv
cd C:\Users\User\Desktop\maps\accounts\Morningside
ren accounts.csv shadbans4.txt
move shadbans4.txt C:\Users\User\Desktop\names
ren spare.txt accounts.csv
cd C:\Users\User\Desktop\maps\accounts\Northside
ren accounts.csv shadbans5.txt
move shadbans5.txt C:\Users\User\Desktop\names
ren spare.txt accounts.csv
cd C:\Users\User\Desktop\maps\accounts\orangecity
ren accounts.csv shadbans6.txt
move shadbans6.txt C:\Users\User\Desktop\names
ren spare.txt accounts.csv
cd C:\Users\User\Desktop\maps\accounts\Riverside
ren accounts.csv shadbans7.txt
move shadbans7.txt C:\Users\User\Desktop\names
ren spare.txt accounts.csv
cd C:\Users\User\Desktop\maps\accounts\Singinghills
ren accounts.csv shadbans8.txt
move shadbans8.txt C:\Users\User\Desktop\names
ren spare.txt accounts.csv
cd C:\Users\User\Desktop\maps\accounts\siouxcenter
ren accounts.csv shadbans9.txt
move shadbans9.txt C:\Users\User\Desktop\names
ren spare.txt accounts.csv
cd C:\Users\User\Desktop\maps\accounts\SouthSioux
ren accounts.csv shadbans10.txt
move shadbans10.txt C:\Users\User\Desktop\names
ren spare.txt accounts.csv
cd C:\Users\User\Desktop\maps\accounts\Westside
ren accounts.csv shadbans11.txt
move shadbans11.txt C:\Users\User\Desktop\names
ren spare.txt accounts.csv
cd C:\Users\User\Desktop\names\
more shadbans.txt >> banned.txt
more shadbans1.txt >> banned.txt
more shadbans2.txt >> banned.txt
more shadbans3.txt >> banned.txt
more shadbans4.txt >> banned.txt
more shadbans5.txt >> banned.txt
more shadbans6.txt >> banned.txt
more shadbans7.txt >> banned.txt
more shadbans8.txt >> banned.txt
more shadbans9.txt >> banned.txt
more shadbans10.txt >> banned.txt
more shadbans11.txt >> banned.txt
more shadbans12.txt >> banned.txt
PAUSE
Last edited by Squashman on 17 Nov 2017 13:20, edited 1 time in total.
Reason: MOD EDIT: Please use code tags.

Squashman
Expert
Posts: 4471
Joined: 23 Dec 2011 13:59

Re: new to batch scripts

#4 Post by Squashman » 17 Nov 2017 13:25

I will shorten your brute force code by 12 lines for you.

Code: Select all

type shadbans*.txt >> banned.txt

mkenney84
Posts: 3
Joined: 16 Nov 2017 10:53

Re: new to batch scripts

#5 Post by mkenney84 » 17 Nov 2017 13:50

ty im just learning what things mean eventually i want to understand it using proper syntax instead of brute force as you say just gotta practice

Post Reply