I have been working with multiple folders, each folder have distinct name and each of them have multiple CSV files inside, i have a bash script that for each csv file inside the folder, makes a folder with the name of the file and makes N copies of the files inside the new folder, in the original bash script, i can write the specifically folder were it runs.
But now, i have a hundred of folders, and i try to automatize this script but it don't works appropriately
#cd grupo_2_pareja_D-H
#cd grupo_2_single_D-H
#cd grupo_2_tercia_CDH
for d in ./*; do
echo "$d"
for x in ./* .csv; do
mkdir "${x%.*}"
for ((i=1;i<=10;i++)); do # Create a loop, looping N times
cp "$x" "${x%.*}/"${x%.*}"_$i.csv" # use i in the copy command
#rm -f "$x" # Remove the file after the N copies
done
done
done
I looking for some help to make this posible, thanks in advance. Regards
Ntimes, once for each of yourNdirectories.fortofor x in "$d"/*.csv; doand see if that gets you closer.https://shellcheck.net, a syntax checker, or installshellchecklocally. Make usingshellcheckpart of your development process.