I am trying to write a shell script that moves all files except those that end with .shand .py. I also do not want to move directories.
This is what I have so far:
cd FILES/user/folder
shopt -s extglob
mv !(*.sh|*.py) MoveFolder/ 2>/dev/null
shopt -u extglob
This moves all files except those that contain .shor .py, but all directories also move to MoveFolder.
I suppose I can rename folders, but other scripts already have those folders that are assigned to work, so renaming can give me more problems. I could also add folder names, but whenever someone creates a folder, I will need to add its name to the script, otherwise it will also be moved.
How can I improve this script to skip all folders?
source
share