Skip to content

Instantly share code, notes, and snippets.

@bahadirdogru
Last active September 7, 2022 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bahadirdogru/e5893ea0255cc00a93a900a4e7111c77 to your computer and use it in GitHub Desktop.
Save bahadirdogru/e5893ea0255cc00a93a900a4e7111c77 to your computer and use it in GitHub Desktop.
# Files are in list of TEST-{Number} folder: TEST-1/01.png TEST-1/02.png...
#
#define indexes
let i_dir=0
let i_file=0
# first loop for directories
# Klasör isimleri TEST ifadesi ile başlamalı
for dir in TEST*/; do
i_dir=$(( i_dir + 1 ))
i_file=0
# second loop for files
# Resimler png uzantılı olmalı
for file in $dir/*.png; do
# Sayı 0 dan başladığı için 1 ekle
i_file=$(( i_file + 1 ))
#echo $file
# copy files
# echo $i_file;
# kopyala:
cp -R SFOLDER/ $dir/"S$i_file";
#echo "$dir/S$i_file";
file_name=$(basename "$file" .png);
#echo $((10#$file_name))
# şimdi TEST1/ içindeki 01.png dosyasını TEST1/S1/soru.png olarak taşıyalım
cp $file $dir/"S$((10#$file_name))"/"soru.png";
mv $file $dir/"S$((10#$file_name))"/"S.png";
done
echo "$i_dir sayılı klasör işlendi.";
done
echo "Toplam Klasör: $i_dir işlendi";
# for pics in TEST*/*.png;do
# #echo ${/%pics%.*};
# let multipler=1;
# file_name=$(basename "$pics" .png);
# #echo $file_name;
# echo $((10#$file_name))
# done
#To force the shell to interpret a number with leading zeros (or any other number) as decimal, you can specify the base as in:
#x=08
#echo $(( 10#$x ))
#This is documented in the Bash Reference manual at the end of the Shell Arithmetic paragraph (§6.5).
#https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Shell-Arithmetic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment