-
Notifications
You must be signed in to change notification settings - Fork 0
/
dir_size(upgrade).bat
95 lines (83 loc) · 2.17 KB
/
dir_size(upgrade).bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
@echo off
setlocal EnableDelayedExpansion
REM Prompt the user for the folder location
set /p "directory_path=Enter the path of the folder you want to analyze: "
REM Check if a directory path is provided
if "%directory_path%" == "" (
echo Error: No directory path provided.
exit /b 1
)
REM Check if the provided directory exists
if not exist "%directory_path%" (
echo Error: Directory '%directory_path%' does not exist.
exit /b 1
)
:menu
REM Display options for the current directory
echo.
echo Currently in directory: %directory_path%
echo.
REM List files in the current directory
echo Files in %directory_path%:
for %%F in ("%directory_path%\*") do (
if "%%~aF" neq "d" (
echo File: %%~nxF - Size: %%~zF bytes
)
)
echo.
echo [1] Navigate to a subfolder
echo [2] Back to parent directory
echo [0] Exit
echo.
REM Prompt user for choice
set /p "choice=Enter your choice: "
REM Process user choice
if "%choice%"=="1" goto navigate_subfolder
if "%choice%"=="2" goto back_to_parent
if "%choice%"=="0" exit
REM Invalid choice
echo Invalid choice. Please try again.
pause
goto menu
:navigate_subfolder
REM Navigate to a subfolder
set /a "option=1"
set "subfolder_path_list="
set "counter=0"
for /d %%D in ("%directory_path%\*") do (
set /a "counter+=1"
echo [!option!] %%~nxD
set "subfolder_path_list=!subfolder_path_list!%%~fD|"
set /a "option+=1"
)
echo.
set /p "subfolder_choice=Enter the number of the subfolder you want to navigate into (or 0 to cancel): "
if "%subfolder_choice%"=="0" goto menu
set "found=false"
for /f "tokens=1,* delims=|" %%a in ("%subfolder_path_list%") do (
if !counter! equ %subfolder_choice% (
set "subfolder_path=%%a"
set "found=true"
goto navigate_to_subfolder
)
set /a "counter-=1"
)
if not %found%==true (
echo Invalid subfolder choice. Please try again.
pause
goto navigate_subfolder
)
:navigate_to_subfolder
if not exist "%subfolder_path%" (
echo Subfolder does not exist. Please try again.
pause
goto navigate_subfolder
)
pushd "%subfolder_path%"
set "directory_path=%CD%"
goto menu
:back_to_parent
REM Back to parent directory
popd
set "directory_path=%CD%"
goto menu