From owner-freebsd-questions@freebsd.org Sat Jan 6 08:55:37 2018 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2C73FE8C8CA for ; Sat, 6 Jan 2018 08:55:37 +0000 (UTC) (envelope-from vas@mpeks.tomsk.su) Received: from relay2.tomsk.ru (mail.sibptus.tomsk.ru [212.73.124.5]) by mx1.freebsd.org (Postfix) with ESMTP id 9B4CE7D46D for ; Sat, 6 Jan 2018 08:55:36 +0000 (UTC) (envelope-from vas@mpeks.tomsk.su) X-Virus-Scanned: by clamd daemon 0.98.5_1 for FreeBSD at relay2.tomsk.ru Received: from [212.73.125.240] (HELO admin.sibptus.transneft.ru) by relay2.tomsk.ru (CommuniGate Pro SMTP 5.1.16) with ESMTPS id 39906980; Sat, 06 Jan 2018 14:50:46 +0600 Received: from admin.sibptus.transneft.ru (sudakov@localhost [127.0.0.1]) by admin.sibptus.transneft.ru (8.15.2/8.15.2) with ESMTP id w068tWtm033246; Sat, 6 Jan 2018 15:55:34 +0700 (+07) (envelope-from vas@mpeks.tomsk.su) Received: (from sudakov@localhost) by admin.sibptus.transneft.ru (8.15.2/8.15.2/Submit) id w068tSE3033245; Sat, 6 Jan 2018 15:55:28 +0700 (+07) (envelope-from vas@mpeks.tomsk.su) X-Authentication-Warning: admin.sibptus.transneft.ru: sudakov set sender to vas@mpeks.tomsk.su using -f Date: Sat, 6 Jan 2018 15:55:28 +0700 From: Victor Sudakov To: Ultima Cc: Polytropon , FreeBSD Mailing List Subject: Re: Convert .flac and .ape to mp3 Message-ID: <20180106085528.GA33117@admin.sibptus.transneft.ru> References: <20180104163421.GA15692@admin.sibptus.transneft.ru> <20180104175156.440fa0c2.freebsd@edvax.de> <20180106063934.GA32231@admin.sibptus.transneft.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: AO "Svyaztransneft", SibPTUS X-PGP-Key: http://www.dreamwidth.org/pubkey?user=victor_sudakov X-PGP-Fingerprint: 10E3 1171 1273 E007 C2E9 3532 0DA4 F259 9B5E C634 User-Agent: Mutt/1.9.1 (2017-09-22) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Jan 2018 08:55:37 -0000 Ultima wrote: > > So eventually I will need to write a script to process all the *.ape > > files, probably with bchunk. Which brings the following question. If > > the file and directory names have spaces in them, a simple loop like > > this: > > > > #!/bin/sh > > for i in `find . -iname '*.ape'` > > do > > do_something $i > > done > > > > breaks on spaces. > > > > What is the sh magic to handle such filenames? > do_something "$i" Nope, these quotes make no difference, they are too late. The problem is in the "for " line, it cannot differentiate spaces _in_ filenames and _between_ filenames. Look: $ touch "this is a long file name.ape" $ ~/bin/ape2mp3.sh + find . -iname '*.ape' + echo ./this ./this + echo is is + echo a a + echo long long + echo file file + echo name.ape name.ape $ I'm sure the solution exists, it must be a very common case. -- Victor Sudakov, VAS4-RIPE, VAS47-RIPN AS43859