Hello, 2014-11-12 12:40 GMT+02:00 Raffaele Morelli <raffaele.more...@gmail.com>:
> On 11/11/14 at 04:09pm, B. M. wrote: > > Hi all, > > > > I'm struggling with a find problem. > > > > I want to combine find and par2create recursively in order to get the > > following done: > > > > Foreach file with a certain suffix (e.g. avi) do par2create for that > > file in its directory, so e.g. > > > > I'm in /video > > There are subfolders user1, user2 with videos video1.avi, video2.avi ... > > in them. > > > > The script should do something equivalent to: > > cd /video/user1 > > par2create .video1.avi video1.avi > > par2create .video2.avi video2.avi > > cd /video/user2 > > par2create .video3.avi video3.avi > > par2create .video4.avi video4.avi > > cd <initial directory> > > > > But I want to achieve this using the find command. > > > One solution should be to use find together with a read loop. Inside the look get needed directory and base file names, and in a subshell jump into the directory and execute the command (in following only using pwd and echo for testing purposes). Another alternative could use pushd/popd commands ... $ *find . -type f -name "*.avi" | \ while read avi do avi_fn=$(basename $avi); avi_dir=$(dirname $avi); ( cd $avi_dir && pwd && echo par2create .${avi_fn} $avi_fn ); done* /tmp/test/e/f par2create .fifth.avi fifth.avi /tmp/test/a/b par2create .first.avi first.avi /tmp/test/a/b par2create .second.avi second.avi /tmp/test/b par2create .sixth.avi sixth.avi /tmp/test/d par2create .third.avi third.avi Here is the contents of the test dir: $ find . -type f ./e/f/fifth.avi ./a/b/first.avi ./a/b/second.avi ./b/sixth.avi ./d/third.avi BR, Roland > > So I'd expect something like > > find * -name "*.avi" -execdir par2create .'{}' '{} \; > > but this doesn't work as expected - it creates the .*.avi files "one > > folder above". > > > > How does it work using the find command? > > > > Thanks a lot! > > I did a test with cp: > find config/ -name custom.php -execdir cp '{}' '{}'.pippo \; > files are copied with added suffix. > > > -- > « Nunc est bibendum, nunc pede libero pulsanda tellus » > > > -- > To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org > with a subject of "unsubscribe". Trouble? Contact > listmas...@lists.debian.org > Archive: https://lists.debian.org/20141112104025.ga1...@gmail.com > >