Change file extension of several files in one command

I'm using a binary to convert a file type to another:

./rcc -binary themes/redTheme.qrc -o redTheme.rcc

I have several .qrc files and would like to convert them as well, but in the same command. How to regroup them rename and their type? I'm struggling to find a way to keep the file name.

I was thinking about binding my rcc binary to a pipe that would execute a loop converting the .qrc files.

Answers


I hope you can bind this with your binary:

ls *.qrc | xargs -I {} sh -c 'mv $1 `basename $1 .html`.rcc' - {}

You could use something like this:

$ for i in *.qrc ; do echo mv -v ${i} ${i%.qrc}.new ; done

See here an example where I have a couple of files with qrc ending and I mv them to .new

$ l
total 0
-rw-r--r--  1 chl  wheel  0 Mar  9 16:22 1.qrc
-rw-r--r--  1 chl  wheel  0 Mar  9 16:22 10.qrc
-rw-r--r--  1 chl  wheel  0 Mar  9 16:22 2.qrc
-rw-r--r--  1 chl  wheel  0 Mar  9 16:22 3.qrc
-rw-r--r--  1 chl  wheel  0 Mar  9 16:22 4.qrc
-rw-r--r--  1 chl  wheel  0 Mar  9 16:22 5.qrc
-rw-r--r--  1 chl  wheel  0 Mar  9 16:22 6.qrc
-rw-r--r--  1 chl  wheel  0 Mar  9 16:22 7.qrc
-rw-r--r--  1 chl  wheel  0 Mar  9 16:22 8.qrc
-rw-r--r--  1 chl  wheel  0 Mar  9 16:22 9.qrc
$ for i in *.qrc ; do mv -v ${i} ${i%.qrc}.new ; done
1.qrc -> 1.new
10.qrc -> 10.new
2.qrc -> 2.new
3.qrc -> 3.new
4.qrc -> 4.new
5.qrc -> 5.new
6.qrc -> 6.new
7.qrc -> 7.new
8.qrc -> 8.new
9.qrc -> 9.new
$ l
total 0
-rw-r--r--  1 chl  wheel  0 Mar  9 16:22 1.new
-rw-r--r--  1 chl  wheel  0 Mar  9 16:22 10.new
-rw-r--r--  1 chl  wheel  0 Mar  9 16:22 2.new
-rw-r--r--  1 chl  wheel  0 Mar  9 16:22 3.new
-rw-r--r--  1 chl  wheel  0 Mar  9 16:22 4.new
-rw-r--r--  1 chl  wheel  0 Mar  9 16:22 5.new
-rw-r--r--  1 chl  wheel  0 Mar  9 16:22 6.new
-rw-r--r--  1 chl  wheel  0 Mar  9 16:22 7.new
-rw-r--r--  1 chl  wheel  0 Mar  9 16:22 8.new
-rw-r--r--  1 chl  wheel  0 Mar  9 16:22 9.new
$

Of course you have to use your rcc tool instead of mv and use your ending instead of .new


Need Your Help

How to assign separate thread for each File System Watcher?

c# .net multithreading windows-services filesystemwatcher

I am developing a database file system.It includes a multi-directory watcher which is a windows service and which uses the file system watcher class from .net.

How can CSS-Modules integrate with this Webpack build?

webpack react-css-modules

Given the Webpack build below, how can I integrate CSS-Modules ( link and example for web pack at link below Webpack config ).