-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorganization
More file actions
43 lines (37 loc) · 1.3 KB
/
organization
File metadata and controls
43 lines (37 loc) · 1.3 KB
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
@echo off
setlocal enabledelayedexpansion
echo Starting file organization...
REM Loop through all files in the current directory
for %%f in (*) do (
REM Skip the batch file itself and directories
if /i not "%%f"=="%~nx0" (
if not exist "%%f\*" (
REM Get the file extension
set "filename=%%f"
set "extension=%%~xf"
REM Remove the dot from extension for folder name
if defined extension (
set "extension=!extension:~1!"
REM Create folder if it doesn't exist
if not exist "!extension!" (
mkdir "!extension!"
echo Created folder: !extension!
)
REM Move the file to the appropriate folder
move "%%f" "!extension!\"
echo Moved %%f to !extension!\ folder
) else (
REM Handle files without extensions
if not exist "no_extension" (
mkdir "no_extension"
echo Created folder: no_extension
)
move "%%f" "no_extension\"
echo Moved %%f to no_extension\ folder
)
)
)
)
echo.
echo File organization complete!
pause