Windows Maximum Path Length
To avoid all these downstream activities in Windows, I 'move' all these files to there respective base directory and delete all these directories. In UNIX, you can achieve that with 'find'
find . -type f -exec mv {} . \; find . -type d -depth rmdir {} \;
First find is to locate all the files (no directory) and execute a 'mv' to move the file to current directory. Second find is to locate all the directories, with the trick that we locate directory with depth first. With this, we are able to delete the deeper directory in the hierarchy. BTW, the second find will generate error 'cos the find also locate itself (".") and rmdir will try to remove it. It will fail 'cos you are not allow to remove itself or non-empty directory. Although it will not do any harm, you may want to avoid error by putting find in a loop and skip the current directory
for i in `find . -type d -depth` do [ "$i" = "." ] || rmdir $i done
Labels: shell script
0 Comments:
Post a Comment
<< Home