Reputation: 592
I use this line to remove blank spaces on folder name
find /tmp/ -depth -name "* *" -execdir rename 's/ /_/g' "{}" \;
Is there a way to remove SPACES and PARENTHESES from filename and put underscore?
For example, I have:
|-- a_dir
| `-- (1) file with spaces and parentheses.pdf
`-- b_dir
|-- (43) another file with spaces (1).pdf
`-- (132) yet another file with spaces (3343).pdf
Must become
|-- a_dir
| `-- 1_file_with_spaces_and_parentheses.pdf
`-- b_dir
|-- 43_another_file_with_spaces_1.pdf
`-- 132_yet_another_file_with_spaces_3343.pdf
Upvotes: 4
Views: 4783
Reputation: 785108
You can use:
find /tmp/ -depth -name "*[ ()]*" -execdir rename 's/[ )]/_/g; s/\(//g' "{}" \;
Upvotes: 6