how to change extensions for many files in other directory path
Hi, I've got to learn how to change the extensions for many files in the working directory using the following command
Code:
for x in *.ext1; do mv "$x" "${x%.ext1}.ext2"; done Hope someone here have an answer, I've been googling a lot about this but couldn't find it. Thanks you in advance. |
Perhaps something like this:
Code:
for x in /path/to/files/*.ext1; do mv "$x" "${x%.ext1}.ext2"; done |
that worked like charm, but not with the first "/", I did it like this:
Code:
for x in path/to/files/*.ext1; do mv "$x" "${x%.ext1}.ext2"; done |
bigrigdriver's example uses an absolute path ie tells the cmd where to start in terms of the entire disk partition ie starting from the root dir.
Yours is a relative path ie it'll only work if that path exists in your current dir. HTH |
Oh My God .. you just need like the following command to do this simple operator:
Code:
mv *.txt *.doc Code:
move *.txt *.doc Code:
ren *.txt *.doc |
Quote:
mv a.txt b.txt *.doc *.doc will be interpreted as a directory and fail. Another ways to do this (my personal favorite): ls /path/to/dir/*.ext1 | sed -e "s/^\(.*\).ext1/\1.ext1 \1.ext2/g" | xargs -n 2 mv -f But alas, someone decided that was too much to bear, so in comes: rename .ext1 .ext2 /path/to/dir/*.ext1 Hehe, hope this helps. |
Thank you,
You can also use rename instead of mv by the same method. Quote:
|
All times are GMT -5. The time now is 12:15 PM. |