I have on a Samba server lots of files in directories/subdirectories containing special chars. The problem is that, the files (containing a special chars) are not visible when I try to view files using Windows.So I wrote command (on the below) to change names of files with special characters, but putting back renamed files to dirs/subdirs doesn't work properly:find . -type f -exec rename -v 's/[^a-zA-Z0-9 &](?=[^.]*\.)/_/g' '{}' \;On the bottom I post current directory containing files to rename:./dir 1/fil[special char]e3.jpg./dir 1/another dir2/m[special char]r.file1.txt./dir 1/another dir2/file[special char]2.doc./dir 3/next dir4/dir 5/fi[special char]le5.xml./file 4.zipExpect - after using command described above (files in dirs/subdirs):./dir 1/fil_e 3.jpg./dir 1/another dir2/m_r_file1.txt./dir 1/another dir2/file_2.doc./dir 3/next dir4/dir 5/fi_le5.xml./file 4.zipreality - files in same folder  where I run command:__dir 1_fil_e 3.jpg__dir 1_another dir 2_m_r_file1.txt__dir 1_another dir 2_file_2.doc__dir 3_next dir4_dir 5_fi_le5.xml__file 4.zipand I have 2 questions:how I can exclude pathname from filename?how to put files in to directories?
How to rename multiple filenames using find/rename
shell;files;find;rename;samba
If you have it, use the -execdir option for find instead of -exec.-exec runs the command from the root of the command with each path as an argument-execdir runs the command in the target directory with each filename as an argumentThus,find . -type f -execdir rename -v 's/[^a-zA-Z0-9 &](?=[^.]*\.)/_/g' '{}' \;