Created
November 22, 2023 10:54
-
-
Save cedricbahirwe/e7390b0954d525b36102d97ba6dfb153 to your computer and use it in GitHub Desktop.
One of those scripts you may need
This file contains 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
#!/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