Created
June 9, 2023 17:34
-
-
Save sadimanna/b8252db82718dbd7b82bd1d760552f03 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal enabledelayedexpansion | |
REM Set the paths for Folder A, train folder, val folder, and test folder | |
set "base_path=C:\Users\ISI_UTS\Siladittya\MIDA2023" | |
set "image_folder_path=%base_path%\images" | |
set "train_image_path=%base_path%\train_images" | |
set "val_image_path=%base_path%\val_images" | |
set "test_image_path=%base_path%\test_images" | |
REM Create the train, val, and test folders if they don't exist | |
mkdir "%train_image_path%" | |
mkdir "%val_image_path%" | |
mkdir "%test_image_path%" | |
REM Clear the train, val, and test folders if they are not empty | |
del /q "%train_image_path%\*" | |
del /q "%val_image_path%\*" | |
del /q "%test_image_path%\*" | |
REM Define the percentage split for train, val, and test (adjust as needed) | |
set "train_split=25" | |
set "val_split=50" | |
set "test_split=100" | |
REM Move files from Folder A to the train, val, and test folders | |
for %%f in ("%image_folder_path%\*") do ( | |
set /a "rand_num=!random! %% 100" | |
if !rand_num! lss %train_split% ( | |
move "%%~ff" "%train_image_path%\" | |
) else if !rand_num! lss %val_split% ( | |
move "%%~ff" "%val_image_path%\" | |
) else ( | |
move "%%~ff" "%test_image_path%\" | |
) | |
) | |
echo Files divided into train, val, and test splits successfully! | |
endlocal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment