Re: filename rename utility?
Aaron wrote: Hi all, lately I have had to deal with a lot of windoze filenames and am wondering if ther is a utility/script to remove the spaces automatically. Thanks Aaron You can use bash replacement feature: # A=Hello This is a test # echo $A Hello This is a test # echo ${A// /} HelloThisisatest A simple for loop and mv should handle it, example: for i in *; do mv $i ${i// /}; done If you have lots files in a dir, it could pose a problem, using find and -exec can help with that. -- Meir Kriheli http://mksoft.co.il = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: filename rename utility?
Aaron [EMAIL PROTECTED] writes: Hi all, lately I have had to deal with a lot of windoze filenames and am wondering if ther is a utility/script to remove the spaces automatically. tr -d ? -- Oleg Goldshmidt | [EMAIL PROTECTED] = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: filename rename utility?
actually, this will not work, since file names with a space in them will be parsed as two (or more) separate words, in the for-loop. Meir Kriheli wrote: Aaron wrote: Hi all, lately I have had to deal with a lot of windoze filenames and am wondering if ther is a utility/script to remove the spaces automatically. Thanks Aaron You can use bash replacement feature: # A=Hello This is a test # echo $A Hello This is a test # echo ${A// /} HelloThisisatest A simple for loop and mv should handle it, example: for i in *; do mv $i ${i// /}; done If you have lots files in a dir, it could pose a problem, using find and -exec can help with that. -- Meir Kriheli http://mksoft.co.il = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED] = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: filename rename utility?
I take this back. Works alright. Yet another case of a enter-happy finger... I guess bash was smarter than letting a space in a filename fool it into thinking it's another word. Sorry. Arnon Klein wrote: actually, this will not work, since file names with a space in them will be parsed as two (or more) separate words, in the for-loop. Meir Kriheli wrote: or i in *; do mv $i ${i// /}; done If you have lots files in a dir, it could pose a problem, using find and -exec can help with that. -- Meir Kriheli http://mksoft.co.il = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: filename rename utility?
Thanks, (why off list?) Thanks Aaron On Tue, 2004-10-26 at 20:24, Meir Kriheli wrote: Aaron wrote: Hi all, lately I have had to deal with a lot of windoze filenames and am wondering if ther is a utility/script to remove the spaces automatically. Thanks Aaron You can use bash replacement feature: # A=Hello This is a test # echo $A Hello This is a test # echo ${A// /} HelloThisisatest A simple for loop and mv should handle it, example: for i in *; do mv $i ${i// /}; done If you have lots files in a dir, it could pose a problem, using find and -exec can help with that. or ls *.txt or find I guess. I will check out the bash replacement feature before I try this so I understand what I am doing. History has proven the danger of blindly copying a script without knowing what I am doing. (my linux history that is ) thanks again -- Meir Kriheli http://mksoft.co.il = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: filename rename utility?
Thanks it works Aaron On Tue, 2004-10-26 at 22:14, Arnon Klein wrote: I take this back. Works alright. Yet another case of a enter-happy finger... I guess bash was smarter than letting a space in a filename fool it into thinking it's another word. Sorry. Arnon Klein wrote: actually, this will not work, since file names with a space in them will be parsed as two (or more) separate words, in the for-loop. Meir Kriheli wrote: or i in *; do mv $i ${i// /}; done If you have lots files in a dir, it could pose a problem, using find and -exec can help with that. -- Meir Kriheli http://mksoft.co.il = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: filename rename utility?
Aaron wrote: You can use bash replacement feature: # A=Hello This is a test # echo $A Hello This is a test # echo ${A// /} HelloThisisatest A simple for loop and mv should handle it, example: for i in *; do mv $i ${i// /}; done If you have lots files in a dir, it could pose a problem, using find and -exec can help with that. or ls *.txt or find I guess. I will check out the bash replacement feature before I try this so I understand what I am doing. History has proven the danger of blindly copying a script without knowing what I am doing. (my linux history that is ) The syntax is: ${var_name/search/replace} ${var_name//search/replace} Note that the 2nd one 2 backslashes after var_name. The former replaces only the 1st occurrence, while the latter replaces all. You can use this method to handle some quick search and replace. Here's another example: Let's create some files to simulate a test scenario: $ for i in `seq 20`; do touch backup$i.log; done $ ls backup10.log backup14.log backup18.log backup2.log backup6.log backup11.log backup15.log backup19.log backup3.log backup7.log backup12.log backup16.log backup1.log backup4.log backup8.log backup13.log backup17.log backup20.log backup5.log backup9.log Note the sort order. Assuming you want all of them to be in the format of backupXX.log $ for i in backup?.log; do mv $i ${i/up/up0}; done $ ls backup01.log backup05.log backup09.log backup13.log backup17.log backup02.log backup06.log backup10.log backup14.log backup18.log backup03.log backup07.log backup11.log backup15.log backup19.log backup04.log backup08.log backup12.log backup16.log backup20.log HTH -- Meir Kriheli http://mksoft.co.il = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: filename rename utility?
wow a bunch of new (to me) tricks up0 and seq20 plus the replace feature. Great instead of an app I got a bash tutorial, this group is great. Thanks Aaron On Wed, 2004-10-27 at 00:37, Meir Kriheli wrote: Aaron wrote: You can use bash replacement feature: # A=Hello This is a test # echo $A Hello This is a test # echo ${A// /} HelloThisisatest A simple for loop and mv should handle it, example: for i in *; do mv $i ${i// /}; done If you have lots files in a dir, it could pose a problem, using find and -exec can help with that. or ls *.txt or find I guess. I will check out the bash replacement feature before I try this so I understand what I am doing. History has proven the danger of blindly copying a script without knowing what I am doing. (my linux history that is ) The syntax is: ${var_name/search/replace} ${var_name//search/replace} Note that the 2nd one 2 backslashes after var_name. The former replaces only the 1st occurrence, while the latter replaces all. You can use this method to handle some quick search and replace. Here's another example: Let's create some files to simulate a test scenario: $ for i in `seq 20`; do touch backup$i.log; done $ ls backup10.log backup14.log backup18.log backup2.log backup6.log backup11.log backup15.log backup19.log backup3.log backup7.log backup12.log backup16.log backup1.log backup4.log backup8.log backup13.log backup17.log backup20.log backup5.log backup9.log Note the sort order. Assuming you want all of them to be in the format of backupXX.log $ for i in backup?.log; do mv $i ${i/up/up0}; done $ ls backup01.log backup05.log backup09.log backup13.log backup17.log backup02.log backup06.log backup10.log backup14.log backup18.log backup03.log backup07.log backup11.log backup15.log backup19.log backup04.log backup08.log backup12.log backup16.log backup20.log HTH -- Meir Kriheli http://mksoft.co.il = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED] = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]