| delorie.com/archives/browse.cgi | search |
| X-Spam-Check-By: | sourceware.org |
| Message-ID: | <45094B84.6010009@byu.net> |
| Date: | Thu, 14 Sep 2006 06:31:00 -0600 |
| From: | Eric Blake <ebb9 AT byu DOT net> |
| User-Agent: | Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.5) Gecko/20060719 Thunderbird/1.5.0.5 Mnenhy/0.7.4.666 |
| MIME-Version: | 1.0 |
| To: | cygwin AT cygwin DOT com, npatsop AT cc DOT uoi DOT gr |
| Subject: | Re: add folder name to filename |
| References: | <450949CF DOT 5050306 AT cc DOT uoi DOT gr> |
| In-Reply-To: | <450949CF.5050306@cc.uoi.gr> |
| X-IsSubscribed: | yes |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sourceware.org/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
| Sender: | cygwin-owner AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| Delivered-To: | mailing list cygwin AT cygwin DOT com |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Nikolaos A. Patsopoulos on 9/14/2006 6:23 AM:
>
> I used the following script but doesn't work under cygwin:
>
> for file in folder*/*; do
> dir=$(basename $(dirname $file) )
> base=$(basename $file)
> mv $file $(dirname $file)/${dir}_${base}
> done
What is the actual error message you are seeing? But I bet the problem is
due to your missing quoting, so your problem is not cygwin-specific. I
would guess that you are having issues due to spaces or other shell
metacharacters in the filenames being interpreted literally.
>
> Does anyone has a suggestion or where I should look?
A good tutorial on shell programming? Hint:
for file in folder*/*; do
dir=$(basename "$(dirname "$file")")
base=$(basename "$file")
mv "$file" "$(dirname "$file")/${dir}_${base}"
done
(That won't work on filenames with \n as the last character, but
fortunately, unless you use cygwin managed mounts, that is not an issue on
cygwin).
- --
Life is short - so eat dessert first!
Eric Blake ebb9 AT byu DOT net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFFCUuD84KuGfSFAYARAn1BAJ41A85ZHvKBAWtKa3tWKO+4fLrh5gCgkw+j
fzK7C9kby5r6M26SQQk2pvo=
=CZVE
-----END PGP SIGNATURE-----
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |