Skip to content
Advertisement

search and rename and mv all files from directories and subdirectories

i have a lot of files 30k directories, 21k files inside direrctories and subdirerctories of txt files with the same name

     ├── cases__in_africa
        │   ├── 2020/10/01.txt
        │   ├── 2020/10/02.txt
        │   ├── 2020/10/03.txt
        │   └── 2020/10/04.txt
        ├── death_in_africa
        │   ├── 2020/10/01.txt
        │   ├── 2020/10/02.txt
        │   ├── 2020/10/03.txt
        │   └── 2020/10/04.txt
2926 directories, 21646 files

i want to search for all files inside a lot of subdirerctories and than rename them to other unique name to move them to other directory.

This command not showing the duplicate files

find . -name "*.txt" -exec mv  "{}" ./all ;

Advertisement

Answer

i find this helpful https://askubuntu.com/questions/1003554/how-to-rename-all-jpg-files-in-all-subdirs-wich-contains-dash-in-linux

find -name '*.txt' -exec bash -c 'mv  "{}" "$RANDOM.txt"' ;
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement