Quote:
|
Originally Posted by zazzybob
Here's a simple starting point....
Code:
$ find dirA -type f -print | while read filename; do
> mv ${filename} ./destDir/`echo ${filename} | sed 's!/!_!g'`
> done
$ find dirA -type f -print
$ ls destDir
dirA_dirB_dirE_file_4 dirA_dirC_dirF_dirI_file_7 dirA_dirC_file_2 dirA_dirD_file_3
dirA_dirB_file_1 dirA_dirC_dirF_file_5 dirA_dirD_dirG_file_6
As you can see, all files are moved from dirA to destDir.
You can then just rm -rf dirA
Cheers
ZB
|
This is the way to do it.
The original script fails because of the
for i in *
statement
The * is evaluated at start of the function and doesn't anticipate on files moved to that directory from a subdirectory.