Results 1 to 5 of 5
Hi, I've got to learn how to change the extensions for many files in the working directory using the following in command line
Code:
for x in *.ext1; do mv ...
- 05-26-2008 #1Just Joined!
- Join Date
- May 2008
- Posts
- 8
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 in command line
but I want to know how to do the same job with specifying a path to another directory that contains the files I want to modify, in other wods, I don't want to navigate to each directory using "cd" to run that command.Code:for x in *.ext1; do mv "$x" "${x%.ext1}.ext2"; done
Hope someone here have the answer, I've been googling very much for this but couldn't find it.
Thanks you in advance.
- 05-26-2008 #2Just Joined!
- Join Date
- Dec 2007
- Posts
- 12
The easiest way would be to take an optional command line argument, leading you to something like this:
Code:if [ -n "$1" ]; then
cd "$1"fi for x in *.ext1; domv "$x" "${x%.ext1}.ext2"done
- 05-26-2008 #3Just Joined!
- Join Date
- May 2008
- Posts
- 8
Thank you very much for your reply
unfortunately, I'm not an expert in these commands, just I need to know where I have to put the path of the directory.
- 05-27-2008 #4
if you just wanna know where to specify the directory path it will be as follows
/path/to/directory is the path to the folder you wanna run the command from.Code:for x in /path/to/directory/*.ext1; do mv "$x" "/path/to/directory/${x%.ext1}.ext2"; doneLinux and me it's a love story
- 05-27-2008 #5Just Joined!
- Join Date
- May 2008
- Posts
- 8
this has worked for me
doneCode:for x in path/to/files/*.ext1; do mv "$x" "${x%.ext1}.ext2";
Thanks


Reply With Quote