user name

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
macoga
Posts: 20
Joined: 03 Oct 2021 09:35

Re: user name

#16 Post by macoga » 11 Oct 2021 07:38

Sorry Squashman, I did what you suggested, but to a begginer doesn´t do much sense, I know that I need a lot of maybe basic knowledge, still don´t know what means a lot of symbols like: (%%x), or (tokens=1,2 delims=:), but I believe that this is the porpuse of this board, and as I learn with your help it help others.

macoga
Posts: 20
Joined: 03 Oct 2021 09:35

Re: user name

#17 Post by macoga » 11 Oct 2021 07:42

Code:

Code: Select all

@echo off
color 0A
CLS
:MENU
ECHO.
ECHO 	Desktop  	C: - 1
ECHO 			D: - 2
ECHO 			E: - 3
ECHO 			F: - 4
ECHO 			G: - 5
ECHO 			H: - 6
ECHO 			I: - 7
ECHO 		     SALIR - 8
ECHO.
set drive=
set /p drive= HOW MANY GIGABYTES USE THE FOLDERS IN EACH PARTITION?
ECHO.
if "%drive%"=="1" (set "drive=%userprofile%\desktop")
)else if "%drive%"=="2" (set "drive=D:"
)else if "%drive%"=="3" (set "drive=E:"
)else if "%drive%"=="4" (set "drive=F:"
)else if "%drive%"=="5" (set "drive=G:"
)else if "%drive%"=="6" (set "drive=H:"
)else if "%drive%"=="7" (set "drive=I:"
)else if "%drive%"=="8" (goto :eof
) else goto :menu

md %drive%\GIGA
if not exist %drive%\GIGA md %drive%\GIGA
for %%x in %drive% do LIST GIGA.TXT >nul 2>nul /-y %drive%\*.%%x %drive%\GIGA
______________________________________________________________________________
This makes a folder call GIGAS, but doesn´t list the amount of gigas on a text inside the gigas folder

Code: Select all

@echo off &setlocal
set "folder=%userprofile%\Desktop"
for /f "tokens=1,2 delims=: " %%a in ('robocopy "%folder%" "%folder%" /L /S /NJH /BYTES /FP /NC /NDL /NFL /TS /XJ /R:0 /W:0') do if /i "%%a"=="Bytes" set "size=%%b"
echo %size% bytes
pause
_____________________________________________________________________________
When I use these alone it gives me the size of the folders on the desktop, but in a DOS windows.
Last edited by aGerman on 11 Oct 2021 10:36, edited 1 time in total.
Reason: code formatting

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: user name

#18 Post by aGerman » 11 Oct 2021 10:41

This makes a folder call GIGAS, but doesn´t list the amount of gigas on a text inside the gigas folder
Unbalanced parentheses, invalid syntax (missing space space between ) and else, and whatever you think for %%x in %drive% do LIST GIGA.TXT >nul 2>nul /-y %drive%\*.%%x %drive%\GIGA should do).

Code: Select all

When I use these alone it gives me the size of the folders on the desktop, but in a DOS windows.
Of course. I don't see any redirection of the ECHO output to a file.
but I believe that this is the porpuse of this board
Actually the commands are well-documented and it's not the purpose of this forum to repeat the help messages of the commands and to teach you the basics. In the first place it's your task to read them and learn/look up the syntax.
Run HELP, or <command> /? (with <command> as placeholder for the actual command like SET or FOR), or look it up in the Command Index on DosTips, or in the official Microsoft documentation.

Steffen

macoga
Posts: 20
Joined: 03 Oct 2021 09:35

Re: user name

#19 Post by macoga » 11 Oct 2021 11:43

thanks aGerman I will look at that index

macoga
Posts: 20
Joined: 03 Oct 2021 09:35

Re: user name

#20 Post by macoga » 16 Oct 2021 11:33

Hello steffen, I am back and after reading, trying, testing I got two things:
1.- a program that tells me who is the user - to be use on the desktop
2.- a program that you started, that tells me the amount of megas used by the folders on my desktop, I solved converting the bytes to megas and writting the output of the Cmd to a text form and put it inside a folder.

I will post both, as I see that a lot of people asked in other boards how to send the CMD result to a text form.

macoga
Posts: 20
Joined: 03 Oct 2021 09:35

Re: user name

#21 Post by macoga » 16 Oct 2021 11:34

Code:
@echo off
color 0A
CLS
ECHO WHAT IS THE USER NAME?
ECHO MACOGA VER.1.0
:MENU
ECHO.
ECHO =================================================================
ECHO this program tells me who is the user
ECHO =================================================================
ECHO.
ECHO Folder on desk - 1
ECHO SALIR - 2
ECHO.
set drive=
set /p drive= You will see a folder with the user name?
ECHO.
if "%drive%"=="1" (set "drive=%username%\"
)else if "%drive%"=="2" (goto :eof
) else goto :menu
md %drive%

macoga
Posts: 20
Joined: 03 Oct 2021 09:35

Re: user name

#22 Post by macoga » 16 Oct 2021 11:36

Code:
@echo off
color 0A
CLS
:MENU
ECHO MACOGA VER 1.0
ECHO Desktop C: - 1
ECHO D: - 2
ECHO E: - 3
ECHO F: - 4
ECHO G: - 5
ECHO H: - 6
ECHO I: - 7
ECHO EXIT - 8
ECHO.
set drive=
set /p drive= HOW MANY GIGABYTES USE THE FOLDERS IN EACH PARTITION?
ECHO.
if "%drive%"=="1" (set "drive=%userprofile%\desktop"
)else if "%drive%"=="2" (set "drive=D:"
)else if "%drive%"=="3" (set "drive=E:"
)else if "%drive%"=="4" (set "drive=F:"
)else if "%drive%"=="5" (set "drive=G:"
)else if "%drive%"=="6" (set "drive=H:"
)else if "%drive%"=="7" (set "drive=I:"
)else if "%drive%"=="8" (goto :eof
) else goto :menu
@echo off
set "folder=%userprofile%\Desktop"
for /f "tokens=1,2 delims=: " %%a in ('robocopy "%folder%" "%folder%" /L /S /NJH /BYTES /FP /NC /NDL /NFL /TS /XJ /R:0 /W:0') do if /i "%%a"=="Bytes" set "size=%%b"
set a=%size%
set b=%11000000%
set /a division=%a%/%b%
set /a result=%size%/%11000000%
md GIGAS
echo %result% MEGABYTES > GIGAS\TOTALDESK1.txt
exit

macoga
Posts: 20
Joined: 03 Oct 2021 09:35

Re: user name

#23 Post by macoga » 16 Oct 2021 11:39

I haven´t tried if the program will work on the other partitions with the commands already listed, or it will need another set of commands.

AR Coding
Posts: 53
Joined: 02 May 2021 21:16

Re: user name

#24 Post by AR Coding » 16 Oct 2021 19:24

First of all the variable b is not going to be defined since %11000000% is undefined and second of all why do you need to set a if you already have size? And Why do you need all this?
macoga wrote:
16 Oct 2021 11:36
set a=%size%
set b=%11000000%
set /a division=%a%/%b%
set /a result=%size%/%11000000%
you can just use

Code: Select all

set /a "result=%size%/11000000"
PS: I think you should stick to 1 post :D

macoga
Posts: 20
Joined: 03 Oct 2021 09:35

Re: user name

#25 Post by macoga » 17 Oct 2021 07:15

Hi there AR Coding, the program seems useless, but it help me a lot as I format a lot of computers and clients asked to save the data they have in diferent partitions. I could use the first code, but then I would have to change to the next partition and do the same, also can do the usual select all the folders and look at the properties for the size, but this way I do it automatically, and know right away how much space I need to backup.

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: user name

#26 Post by ShadowThief » 18 Oct 2021 05:44

%11000000% isn't a valid variable, though.

It's %1 (the first argument that the script receives), followed by 1000000, followed by % (which won't do anything since there's only one %)

Post Reply