From: Atropo on 2 Jul 2010 15:41 Hi, all I took this script suggested by Stephane CHAZELAS find . -name "* .txt" -exec sh -c 'file=$1; exec mv "${file}" "${file % .txt}.txt"' {} {} \; this was intended to rename files, but i want create new files with same name but another extension. find . -type f -name PPpldate.jpg -exec sh -c 'file=$1; -exec touch "$ {file%.*}.png"' {} {} \; ../tmp/PPpldate.pl: bad substitution I guess is the last two {}, but not sure, not enough documentation. Solaris 5.10 thanks
From: Ben Bacarisse on 2 Jul 2010 17:30 Atropo <lxvasquez(a)gmail.com> writes: > I took this script suggested by Stephane CHAZELAS > > find . -name "* .txt" -exec sh -c 'file=$1; exec mv "${file}" "${file > % .txt}.txt"' {} {} \; I think some stray spaces have crept in there in addition to the newline which is at least obvious. > this was intended to rename files, but i want create new files with > same name but another extension. > > find . -type f -name PPpldate.jpg -exec sh -c 'file=$1; -exec touch "$ > {file%.*}.png"' {} {} \; > > ./tmp/PPpldate.pl: bad substitution Hmm. There is some evidence that this is not what you typed. Please use some cut and paste method so that you post exactly what was entered. > I guess is the last two {}, but not sure, not enough documentation. No, they are fine. I'd do this: find . -type f -name \*.jpg -exec sh -c 'touch "${1%.*}.png"' {} {} \; but please test it first by replacing touch with something like echo. -- Ben.
|
Pages: 1 Prev: Parse a line? Next: newbie: using find to touch new files |