Skip to content

Instantly share code, notes, and snippets.

@sadimanna
Created June 9, 2023 13:16
Show Gist options
  • Save sadimanna/7a63987535945fc5f3bed69296b23424 to your computer and use it in GitHub Desktop.
Save sadimanna/7a63987535945fc5f3bed69296b23424 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Set the paths for the train folder, label folder, and target folder
train_folder_path="/path/to/train"
label_folder_path="/path/to/label"
target_folder_path="/path/to/target"
label_ext = ".labext"
# Create the target folder if it doesn't exist
mkdir -p "$target_folder_path"
# Clear the target folder if it is not empty
rm -rf "$target_folder_path"/*
# Loop through the files in the train folder
for file in "$train_folder_path"/*; do
# Get the base filename without the extension
filename=$(basename "$file" | cut -d. -f1)
# Move the label file with the same name to the target folder
mv "$label_folder_path/$filename$label_ext" "$target_folder_path"
done
echo "Label files moved successfully!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment