I have written a simple script, to copy some files, and change there name:
#!/bin/bash
for directory in ./../old_files/*; do
DIR_NAME=$(basename $directory)
for file in $directory/*; do
filename=$(basename -- "$file")
cp -- $file "./${DIR_NAME}_m*${filename}" 1>/dev/null
done
done
And it's working great with one problem. If file has an accent or name is escaped with slash, it returns:
cp: target 'xxx.pdf' is not a directory
Any ideas how to solve this?