syntax error near unexpected token `if'

I get

linux-wbbw:~ # /usr/local/bin/importlocal
/usr/local/bin/importlocal: line 3: syntax error near unexpected token if' /usr/local/bin/importlocal: line 3: if -d “$file” && ! -L “$file” ]]; then’
linux-wbbw:~ #

Running the code

#!/bin/bash
for file in /run/media/root/DFSFAT32/usr/local/bin/*
if -d “$file” && ! -L “$file” ]]; then
dos2unix --keepdate --newfile --convmode iso -437 /run/media/root/DFSFAT32/usr/local/bin/$file /usr/local/bin/$file
chmod -a -v 755 /usr/local/bin/$file
fi;
done
for file in /run/media/root/DFSFAT32/usr/local/THE/*
do
if -d “$file” && ! -L “$file” ]]; then
dos2unix --keepdate -c iso -437 -n /run/media/root/DFSFAT32/usr/local/THE/$file /usr/local/THE/$file
chmod -a -v 755 /usr/local/THE/$file
fi;
done

Yoyr “for” has no “do”, but is followed by an “if”.

BTW, when you are needing help with programming/scripting, there is a special sub-forum for it.

[LEFT]1. Metz’s law - you see what you expect to see; that’s what’s nice about a fresh pair of eyes. In this case, two blocks of code with the “identical” structure were different; one did have the do.

  1. What is the forum for questions related to scripts? Thanks.[/LEFT]

Oh yes, that is very true. We humans are very good in seeing what we think we should see. Computers are stupid anough to only see what is there.:slight_smile:

From the main page: Development. And then the top most Programming/Scripting.