Subject: Re: add folder name to filename
From: "Nikolaos A. Patsopoulos" <[email-masked]>
To: Eric Blake <[email-masked]>
Cc: [email-masked]
Date: Thu, 14 Sep 2006 16:08:53 +0300

Eric Blake wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> According to Nikolaos A. Patsopoulos on 9/14/2006 6:35 AM:
>
>   
>> I get the same error with my code and yours:
>>     
>
>   
>> Script started, file is typescript
>>     
>
>   
>> nothing happens, except an empty file called typescript in the parent
>> directory
>>     
>
> We actually need to see a reproducible test case, complete with ACTUAL
> error messages from the console, not a description of what happened.
> Otherwise we don't know what went wrong to try to help.
>
> Reread this link:
>   
>> Problem reports:       http://cygwin.com/problems.html
>>     
>
> You could also try 'echo folder*/*' to see what files are being visited in
> the for loop, or even download the bashdb package using setup.exe and use
> the bash debugger to single step through the loop to try to spot your
> error.  But this is working just fine for me, so you will have to try
> harder before I will be convinced that this is a cygwin-specific bug.
>
> - --
> Life is short - so eat dessert first!
>
> Eric Blake             [email-masked]
> volunteer cygwin bash/bashdb maintainer
> -----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
>
> iD8DBQFFCU6J84KuGfSFAYARAhp/AKCFI9mWV74UxM7IWi+OHmfFPGk08ACcCPkB
> IUrvHBN/xzzYWeL/8pVjV74=
> =ZRwy
> -----END PGP SIGNATURE-----
>
>
>   
Fixed :
added a space after "folder":
for file in folder */*; do
    echo folder */*
     dir=$(basename "$(dirname "$file")")
     base=$(basename "$file")
     mv "$file" "$(dirname "$file")/${dir}_${base}"
done

Thanks a lot Eric!

Nikos

--
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/