[kwlug-disc] Need some advice/assistance on a script

unsolicited unsolicited at swiz.ca
Tue Jun 18 13:36:19 EDT 2013


That's part of the point of the use of wildcards in my suggestion. 
Avoids all that aggravation.

On 13-06-18 01:26 PM, R. Brent Clements wrote:
> Khalid:  by inserting an "echo $FILE" in the if statement, I am seeing
> "Wanted/SFMW894/SFMW894-09"  Every part of the directory name is being
> truncated differently. The lowest directory is "SFMW891 to SFMW920 - Sunfly
> Most Wanted", the next one is correct in this case, but possibly only
> because it includes no spaces, and then the filename is truncated after the
> first space.
>
> Is this possibly a shell issue?  I am using the default shell in xubuntu.
>
> Brent
>
>
> On Tue, Jun 18, 2013 at 12:56 PM, unsolicited <unsolicited at swiz.ca> wrote:
>
>> Ech!
>>
>> 'rm -fr <mytopdir>'
>>
>> should probably be 'rmdir -pv <mytopdir>'
>>
>> Anything left behind is non-empty and needs further investigation.
>>
>> If you check and don't care about anything left behind, then run the 'rm
>> -fr'.
>>
>>
>> On 13-06-18 12:52 PM, unsolicited wrote:
>>
>>> Would:
>>>
>>> cd <mytopdir>
>>> find . -type d -execdir "mv -fv * <myparentdir>" \;
>>> rm -fr <mytopdir>
>>>
>>> do it?
>>>
>>> i.e. find the directories, within each found directory, execute the
>>> command.
>>>
>>> - don't move under topdir, to facilitate rm <mytopdir>
>>> (mv <newdir> <mytopdir> after the fact if useful)
>>>
>>> - probably want a v or inquire on that last rm, just in case something
>>> didn't move.
>>>
>>> On 13-06-18 12:15 PM, Khalid Baheyeldin wrote:
>>>
>>>> cd /your_directory
>>>>
>>>> # Iterate through files
>>>> for FILE in `find . -type f`
>>>> do
>>>>     # Don't move the file if it is already in the root directory
>>>>     if [ `dirname $FILE` != '.' ]; then
>>>>       mv $FILE .
>>>>     fi
>>>> done
>>>>
>>>> # Remove the directories
>>>> for DIR in `find . -type d`
>>>> do
>>>>     if [ `dirname $FILE` != '.' ]; then
>>>>       rm -rf $DIR
>>>>     fi
>>>> done
>>>>
>>>> On Tue, Jun 18, 2013 at 11:55 AM, R. Brent Clements
>>>> <rbclemen at gmail.com>wrote:
>>>>
>>>>   I need to do something dramatically destructive.  I want to take a large
>>>>> directory tree of folders, and collapse them all down to their root
>>>>> folder.  File collisions are irrelevant.  How would you guys do this?
>>>>> (assume for the moment that you would).
>>>>>
>>>>> ______________________________**_________________
>>>>> kwlug-disc mailing list
>>>>> kwlug-disc at kwlug.org
>>>>> http://kwlug.org/mailman/**listinfo/kwlug-disc_kwlug.org<http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> ______________________________**_________________
>>>> kwlug-disc mailing list
>>>> kwlug-disc at kwlug.org
>>>> http://kwlug.org/mailman/**listinfo/kwlug-disc_kwlug.org<http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org>
>>>>
>>>>
>>>
>>> ______________________________**_________________
>>> kwlug-disc mailing list
>>> kwlug-disc at kwlug.org
>>> http://kwlug.org/mailman/**listinfo/kwlug-disc_kwlug.org<http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org>
>>>
>>
>>
>> ______________________________**_________________
>> kwlug-disc mailing list
>> kwlug-disc at kwlug.org
>> http://kwlug.org/mailman/**listinfo/kwlug-disc_kwlug.org<http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org>
>>
>
>
>
> _______________________________________________
> kwlug-disc mailing list
> kwlug-disc at kwlug.org
> http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org
>





More information about the kwlug-disc mailing list