Skip to content

Instantly share code, notes, and snippets.

@cedricbahirwe
Created November 22, 2023 10:54
Show Gist options
  • Save cedricbahirwe/e7390b0954d525b36102d97ba6dfb153 to your computer and use it in GitHub Desktop.
Save cedricbahirwe/e7390b0954d525b36102d97ba6dfb153 to your computer and use it in GitHub Desktop.
One of those scripts you may need
#!/bin/bash
# Set the paths for the folders
folderA="/path/to/A"
folderB="$folderA/B"
folderC="$folderA/C"
# Check if folders exist
if [ ! -d "$folderA" ] || [ ! -d "$folderB" ] || [ ! -d "$folderC" ]; then
echo "Error: One or more folders do not exist."
exit 1
fi
# Loop through files in folder B
for file in "$folderB"/*.java; do
filename=$(basename -- "$file")
filename_noext="${filename%.*}"
new_filename="${filename_noext}Controller.java"
if [ ! -e "$folderC/$new_filename" ]; then
touch "$folderC/$new_filename"
echo "Created empty file $folderC/$new_filename"
else
echo "File $new_filename already exists in $folderC"
fi
done
echo "Script completed."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment