CLI wildcards
Having a hard time finding the answer to this one.
As an example, say I have a directory of document files. They all end in .doc and I wanted to change them all to .txt. What would be the appropriate wildcard arguement to preserve the filenames but change the extension? |
You can try this:
Code:
rename ".doc" ".txt" *.doc |
Simply put, "*.doc". However, many Windows types of files have spaces in them, so you need to be careful.
You can't just do: mv *.doc *.txt, as that doesn't make sense. What you want to do is a little shell command like: for i in *.doc ; do n=`basename "$i" .doc` mv "$i" "$n".txt done Note that the quote marks are required if your filenames have spaces in them. |
I'm sure you can use sed. Unfortunately I am not very good at shell scripting so can't post a script. However, take a look here, there could be an answer for you.
|
rename is the easiest. Just make certain you use "*.doc" as the last argument, to make certain you get the files with spaces in their names.
|
All times are GMT -5. The time now is 01:00 PM. |