I have a recursive structure of directories containing some foo files that I want to convert to bar files using a XSLT 1.0 stylesheet. I have:
dir
|-- subdir
| |-- file1.foo
| |-- file2.foo
| |-- file3.foo
And I want to obtain:
dir
|-- subdir
| |-- file1.foo
| |-- file1.bar
| |-- file2.foo
| |-- file2.bar
| |-- file3.foo
| |-- file3.bar
To capture the basename of files without the extension, I have tried:
$ find . -type f -exec java -jar C:/saxon6-5-5/saxon.jar -o $(basename {} .foo).bar {} stylesheet.xsl \;
and
$ find . -type f -exec java -jar C:/saxon6-5-5/saxon.jar -o `basename {} .foo`.bar {} stylesheet.xsl \;
Both with identical result:
dir
|-- subdir
| |-- file1.foo
| |-- file1.foo.bar
| |-- file2.foo
| |-- file2.foo.bar
| |-- file3.foo
| |-- file3.foo.bar
It seems the basename command is not working. What can I be doing wrong?
Here's a zsh approach, since it's tagged it as such.
for f in **/*.foo(.); print -- java ... -o $f:r.bar $f
Remove the print -- when you're satisfied that it looks good.
The (.) says files only. The :r says remove the .foo extension. It's helpful to remember the path manipulators as "erth" for extension/remove/tail/head.
There's also zmv with the -p option to call your java command.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With