Results 1 to 2 of 2
Hello,
I am trying to write a command to rename files and/or directories by replace non ascii alpha-numeric character. For this topic I will consider replacing space (" ") by ...
- 09-10-2009 #1Just Joined!
- Join Date
- Sep 2009
- Posts
- 1
find and space in file name
Hello,
I am trying to write a command to rename files and/or directories by replace non ascii alpha-numeric character. For this topic I will consider replacing space (" ") by underscore ("_") in filenames.
First I wrote :
It works well but does not treat subdirectories...Code:for i in *; do mv "$i" `echo $i | tr ' ' '_'`; done
So I wanted to try with find :
But it does not work.Code:find . -type f -execdir mv "{}" `echo "{}" | tr ' ' '_'` ";"
For information:
in a filetree like
racine
- sub dir
- other onereturns:Code:find racine -type f -execdir echo `echo "{}" | tr ' ' '_'` ";"
We can see that the space have not been deleted...sub dir
other one
Does somebody know why ?
- 09-27-2009 #2Linux Newbie
- Join Date
- Jan 2008
- Location
- Canada
- Posts
- 109
Hi ktk
I am unable to help with your direct question but I thank you for your first line of code. It has helped me with a problem I have been struggling with for several weeks. If you ever solve your question please post back as many can benefit by your solution. You obviously have a lot of skill with CLI cammands. Cheers...
Robert


Reply With Quote