Rename child directories and directories

1

I'd like to know how a bash code is made to rename all files of a certain extent and folders that begin with an expecific name. The repository that I want to make changes to:

link

For example:

1.in - > 01.in 1.out - > 01.out

3_Flux -> 03_Flux 4_Subalgorithms - > 04_Subalgoritmos

Only those 3 cases, files with extension .in, .out, and folders, and start with a number less than 10, if not less than 10, the 0 does not need to be added.

    
asked by anonymous 06.10.2016 / 15:51

1 answer

0

Accessing each directory, you can rename all files within it using:

rename 's/^/0/' * , for a specific extension, just change * to rename 's/^/0/' *.in

or also:

for file in $(ls); do mv $file 0${file}; done

    
17.10.2016 / 19:57