i have so many files under 300 different directories, file tree like:
--s1
- ----abc
- ----bcd
--s2
- ----123
- ----234
... etc.
I want to put them together under the same directory, like:
--whole
- ----abc
- ----bcd
- ----123
- ----234 ...
Is there any useful bash script in practical?
I coded this piece of bash script:
mkdir wavs
for ((i=1;i<=9;i++)); do
cd ~/wav/train/S000$i
mv * ~/wav/train/wavs
cd .. done
for ((i=10;i<=99;i++)); do
cd ~/wav/train/S00$i
mv * ~/wav/train/wavs
cd .. done
for ((i=100;i<=917;i++)); do
cd ~/wav/train/S0$i
mv * ~/wav/train/wavs
cd .. done
echo "ok"
but i got the error which i dont understand:
./untar.sh: line 24: cd: /wav/train/S0917: No such file or directory
cp: target '/wav/train/wavs/' is not a directory ok
find
, that IMO is the easiest way to do this job. If you need to create a bash script here is provided two variants that solve a similar task: https://askubuntu.com/a/1020671/566421 – pa4080 Apr 02 '18 at 09:57