My code works, but not the way I want. Basically, what my code does is that it looks at the current directory, looks for folders, and in these folders it looks at files. If one of the file extensions is the value of the $ Example variable, then it should delete all other files with the same source file name, regardless of the extension, and rename one with the $ Example extension with the same name, just without the $ Example extension. Here is the code:
#!/bin/sh
set -o errexit
Example=dummy
for d in *; do
if test "$(ls -A "$d" 2>/dev/null)"; then
if [ $(ls -1 ${d}/*.$Example 2>/dev/null | wc -l) -ge 1 ]; then
cd $(pwd)/$d;
for f in *.$Example; do
fileName="${f%.$Example}";
mv "$f" "${f%.$Example}";
listToDelete=$(find -name "$fileName.*");
for g in $listToDelete; do
rm $g;
done;
done;
cd ..;
fi;
fi;
done
VIM, , Linux Windows. - , , , \r, . , , , mv, Linux, , , , .